Merge pull request #1 from DianeXD/master

Update pattern terminal
This commit is contained in:
Martin Robertz authored and GitHub committed 2022-07-09 15:45:24 +07:00
commit 7c929f912e
16 files changed
+408 -250

No files matched your search

+2 -2
View File
@@ -1,8 +1,8 @@
// Add your dependencies here
dependencies {
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.12-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-75-GTNH:dev')
compile('com.github.GTNewHorizons:NotEnoughItems:2.2.17-GTNH:dev')
compile('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-87-GTNH:dev')
compile('curse.maven:cofh-core-69162:2388751')
compile('com.github.GTNewHorizons:ExtraCells2:2.5.9:dev') {transitive = false}
compile("com.github.GTNewHorizons:ForestryMC:4.4.4:dev")
@@ -2,9 +2,11 @@ package com.glodblock.github.client.gui;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.PatternSlotConfig;
import appeng.api.config.Settings;
import appeng.api.storage.ITerminalHost;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.container.slot.AppEngSlot;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBasePartContainerEx;
@@ -16,6 +18,7 @@ import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;
public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
@@ -27,14 +30,20 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiImgButton encodeBtn;
private GuiImgButton invertBtn;
private GuiImgButton clearBtn;
private GuiImgButton doubleBtn;
private final GuiScrollbar processingScrollBar = new GuiScrollbar();
public GuiBaseFluidPatternTerminalEx(final InventoryPlayer inventoryPlayer, final ITerminalHost te )
{
super( inventoryPlayer, te, new FCBasePartContainerEx( inventoryPlayer, te ) );
this.container = (FCBasePartContainerEx) this.inventorySlots;
Ae2ReflectClient.setReservedSpace(this, 81);
processingScrollBar.setHeight(70).setWidth(7).setLeft(6).setRange(0, 1, 1);
processingScrollBar.setTexture(FluidCraft.MODID, "gui/pattern3.png", 242, 0);
}
@Override
@@ -44,19 +53,23 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
if( this.encodeBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Encode", isShiftKeyDown() ? "2" : "1" ) );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Encode", isShiftKeyDown() ? "2" : "1" ) );
}
else if( this.clearBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Clear", "1" ) );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Clear", "1" ) );
}
else if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) );
}
else if( this.invertBtn == btn )
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Invert", container.inverted ? "0" : "1" ) );
}
else if (ModAndClassUtil.isDoubleButton && doubleBtn == btn)
{
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminal.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") );
FluidCraft.proxy.netHandler.sendToServer( new CPacketFluidPatternTermBtns( "PatternTerminalEx.Double", Keyboard.isKeyDown( Keyboard.KEY_LSHIFT ) ? "1": "0") );
}
}
@@ -74,6 +87,10 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
this.substitutionsDisabledBtn.setHalfSize( true );
this.buttonList.add( this.substitutionsDisabledBtn );
invertBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 153, Settings.ACTIONS, container.inverted ? PatternSlotConfig.C_4_16 : PatternSlotConfig.C_16_4);
invertBtn.setHalfSize( true );
this.buttonList.add( this.invertBtn );
this.clearBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE );
this.clearBtn.setHalfSize( true );
this.buttonList.add( this.clearBtn );
@@ -86,6 +103,8 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
this.doubleBtn.setHalfSize( true );
this.buttonList.add( this.doubleBtn );
}
processingScrollBar.setTop(this.ySize - 164);
}
@Override
@@ -107,12 +126,13 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
super.drawFG( offsetX, offsetY, mouseX, mouseY );
this.fontRendererObj.drawString( StatCollector.translateToLocal(NameConst.GUI_FLUID_PATTERN_TERMINAL_EX), 8, this.ySize - 96 + 2 - Ae2ReflectClient.getReservedSpace(this), 4210752 );
this.processingScrollBar.draw(this);
}
@Override
protected String getBackground()
{
return "gui/pattern3.png";
return container.inverted ? "gui/pattern4.png" : "gui/pattern3.png";
}
@Override
@@ -128,4 +148,82 @@ public class GuiBaseFluidPatternTerminalEx extends GuiFCBaseMonitor {
}
}
@Override
public void drawScreen( final int mouseX, final int mouseY, final float btn )
{
if (container.substitute) {
substitutionsEnabledBtn.visible = true;
substitutionsDisabledBtn.visible = false;
} else {
substitutionsEnabledBtn.visible = false;
substitutionsDisabledBtn.visible = true;
}
final int offset = container.inverted? 18 * -3: 0;
substitutionsEnabledBtn.xPosition = this.guiLeft + 97 + offset;
substitutionsDisabledBtn.xPosition = this.guiLeft + 97 + offset;
doubleBtn.xPosition = this.guiLeft + 97 + offset;
clearBtn.xPosition = this.guiLeft + 87 + offset;
invertBtn.xPosition = this.guiLeft + 87 + offset;
processingScrollBar.setCurrentScroll(container.activePage);
super.drawScreen(mouseX, mouseY, btn);
}
@Override
protected void mouseClicked( final int xCoord, final int yCoord, final int btn )
{
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, xCoord - this.guiLeft, yCoord - this.guiTop);
super.mouseClicked(xCoord, yCoord, btn);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
protected void mouseClickMove( final int x, final int y, final int c, final long d )
{
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.click(this, x - this.guiLeft, y - this.guiTop );
super.mouseClickMove(x, y, c, d);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
@Override
public void handleMouseInput()
{
super.handleMouseInput();
final int wheel = Mouse.getEventDWheel();
if (wheel != 0) {
final int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
final int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight;
if (this.processingScrollBar.contains(x - this.guiLeft, y - this.guiTop)) {
final int currentScroll = this.processingScrollBar.getCurrentScroll();
this.processingScrollBar.wheel(wheel);
if (currentScroll != this.processingScrollBar.getCurrentScroll()) {
changeActivePage();
}
}
}
}
private void changeActivePage()
{
FluidCraft.proxy.netHandler.sendToServer(new CPacketFluidPatternTermBtns("PatternTerminalEx.ActivePage", String.valueOf(this.processingScrollBar.getCurrentScroll())));
}
}
@@ -31,12 +31,9 @@ import appeng.util.Platform;
import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.FCBaseMonitorContain;
import com.glodblock.github.client.gui.container.FCBasePartContainer;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.network.CPacketInventoryAction;
import com.glodblock.github.util.Ae2ReflectClient;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.EntityPlayer;
@@ -94,14 +91,9 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
this.setScrollBar( scrollbar );
this.repo = new ItemRepo( scrollbar, this );
this.xSize = 185;
this.xSize = 195;
this.ySize = 204;
if( te instanceof IViewCellStorage)
{
this.xSize += 33;
}
this.standardSize = this.xSize;
this.configSrc = ( (IConfigurableObject) this.inventorySlots ).getConfigManager();
@@ -312,7 +304,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
if( s instanceof AppEngSlot)
{
if( ( (Slot) s ).xDisplayPosition < 197 )
if( ( (Slot) s ).xDisplayPosition < 195 )
{
this.repositionSlot( (AppEngSlot) s );
}
@@ -589,7 +581,7 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
this.bindTextureBack( this.getBackground() );
final int x_width = 197;
final int x_width = 195;
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
if( this.viewCell )
@@ -759,4 +751,31 @@ public class GuiFCBaseMonitor extends AEBaseMEGui implements ISortSource, IConfi
{
return searchField.isMouseIn(x,y);
}
public boolean hideItemPanelSlot(int tx, int ty, int tw, int th)
{
if (this.viewCell) {
int rw = 33;
int rh = 14 + myCurrentViewCells.length * 18;
if (rw <= 0 || rh <= 0 || tw <= 0 || th <= 0) {
return false;
}
int rx = this.guiLeft + this.xSize;
int ry = this.guiTop + 0;
rw += rx;
rh += ry;
tw += tx;
th += ty;
// overflow || intersect
return (rw < rx || rw > tx) && (rh < ry || rh > ty) && (tw < tx || tw > rx) && (th < ty || th > ry);
}
return false;
}
}
@@ -23,9 +23,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import java.util.ArrayList;
import java.util.List;
public class ContainerFluidPatternTerminal extends FCBasePartContainer implements PatternConsumer {
public ContainerFluidPatternTerminal(InventoryPlayer ip, ITerminalHost monitorable) {
@@ -112,23 +109,22 @@ public class ContainerFluidPatternTerminal extends FCBasePartContainer implement
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
List<IAEItemStack> acc = new ArrayList<>();
for (Slot slot : slots) {
ItemStack stack = slot.getStack();
if (stack == null) {
continue;
}
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
acc.add(dropStack);
continue;
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
acc.add(aeStack);
stacks[i] = aeStack;
}
return acc.toArray(new IAEItemStack[0]);
return stacks;
}
@Override
@@ -4,8 +4,7 @@ import appeng.api.AEApi;
import appeng.api.definitions.IDefinitions;
import appeng.api.storage.ITerminalHost;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.slot.SlotFakeCraftingMatrix;
import appeng.container.slot.SlotPatternOutputs;
import appeng.container.slot.OptionalSlotFake;
import appeng.helpers.InventoryAction;
import appeng.util.item.AEItemStack;
import com.glodblock.github.common.item.ItemFluidDrop;
@@ -23,9 +22,6 @@ import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import java.util.ArrayList;
import java.util.List;
public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx implements PatternConsumer {
public ContainerFluidPatternTerminalEx(InventoryPlayer ip, ITerminalHost monitorable) {
@@ -109,23 +105,22 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
private static IAEItemStack[] collectInventory(Slot[] slots) {
// see note at top of FluidPatternDetails
List<IAEItemStack> acc = new ArrayList<>();
for (Slot slot : slots) {
ItemStack stack = slot.getStack();
if (stack == null) {
continue;
}
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
acc.add(dropStack);
continue;
IAEItemStack[] stacks = new IAEItemStack[slots.length];
for (int i = 0; i < stacks.length; i++) {
ItemStack stack = slots[i].getStack();
if (stack != null) {
if (stack.getItem() instanceof ItemFluidPacket) {
IAEItemStack dropStack = ItemFluidDrop.newAeStack(ItemFluidPacket.getFluidStack(stack));
if (dropStack != null) {
stacks[i] = dropStack;
continue;
}
}
}
IAEItemStack aeStack = AEItemStack.create(stack);
acc.add(aeStack);
stacks[i] = aeStack;
}
return acc.toArray(new IAEItemStack[0]);
return stacks;
}
@Override
@@ -155,8 +150,7 @@ public class ContainerFluidPatternTerminalEx extends FCBasePartContainerEx imple
super.doAction(player, action, slotId, id);
return;
}
if ((slot instanceof SlotFakeCraftingMatrix || slot instanceof SlotPatternOutputs) && stack != null
&& (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
if ((slot instanceof OptionalSlotFake) && stack != null && (stack.getItem() instanceof IFluidContainerItem || FluidContainerRegistry.isContainer(stack))) {
FluidStack fluid = null;
switch (action) {
case PICKUP_OR_SET_DOWN:
@@ -565,7 +565,7 @@ public class FCBasePartContainer extends FCBaseMonitorContain implements IAEAppE
List<SlotFake> enabledSlots = Arrays.stream(slots).filter(SlotFake::isEnabled).collect(Collectors.toList());
long emptyStots = enabledSlots.stream().filter(s -> s.getStack() == null).count();
long fullSlots = enabledSlots.stream().filter(s-> s.getStack() != null && s.getStack().stackSize * 2 > 127).count();
return fullSlots <= emptyStots;
return fullSlots <= emptyStots && emptyStots < enabledSlots.size();
}
static void doubleStacksInternal(SlotFake[] slots)
@@ -32,36 +32,62 @@ import java.util.stream.Collectors;
public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket {
private static final int CRAFTING_GRID_PAGES = 2;
private static final int CRAFTING_GRID_WIDTH = 4;
private static final int CRAFTING_GRID_HEIGHT = 4;
private static final int CRAFTING_GRID_SLOTS = CRAFTING_GRID_WIDTH * CRAFTING_GRID_HEIGHT;
private static class ProcessingSlotFake extends OptionalSlotFake {
private static final int POSITION_SHIFT = 9000;
private boolean hidden = false;
public ProcessingSlotFake(IInventory inv, IOptionalSlotHost containerBus, int idx, int x, int y, int offX, int offY, int groupNum) {
super(inv, containerBus, idx, x, y, offX, offY, groupNum);
this.setRenderDisabled(false);
}
public void setHidden(boolean hide) {
if (this.hidden != hide) {
this.hidden = hide;
this.xDisplayPosition += (hide ? -1 : 1) * POSITION_SHIFT;
}
}
}
private final PartFluidPatternTerminalEx patternTerminal;
protected final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[16];
protected final OptionalSlotFake[] outputSlots = new OptionalSlotFake[4];
protected final ProcessingSlotFake[] craftingSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final ProcessingSlotFake[] outputSlots = new ProcessingSlotFake[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
protected final SlotRestrictedInput patternSlotIN;
protected final SlotRestrictedInput patternSlotOUT;
@GuiSync( 96 )
@GuiSync( 96 + (17-9) + 12 )
public boolean substitute = false;
@GuiSync( 96 + (17-9) + 16 )
public boolean inverted;
@GuiSync( 96 + (17-9) + 17 )
public int activePage = 0;
public FCBasePartContainerEx(final InventoryPlayer ip, final ITerminalHost monitorable )
{
super( ip, monitorable, false );
this.patternTerminal = (PartFluidPatternTerminalEx) monitorable;
this.inverted = patternTerminal.isInverted();
final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
final IInventory output = this.getPatternTerminal().getInventoryByName( "output" );
IInventory crafting = this.getPatternTerminal().getInventoryByName("crafting");
for( int y = 0; y < 4; y++ )
{
for( int x = 0; x < 4; x++ )
{
this.addSlotToContainer( this.craftingSlots[x + y * 4] = new SlotFakeCraftingMatrix(crafting, x + y * 4, 15 + x * 18, -83 + y * 18 ) );
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.addSlotToContainer(this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(crafting, this, x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS, 15, -83, x, y, x + 4));
}
}
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
this.addSlotToContainer(this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS] = new ProcessingSlotFake(output, this, x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS, 112, -83, -x, y, x));
}
}
}
for( int y = 0; y < 4; y++ )
{
this.addSlotToContainer( this.outputSlots[y] = new SlotPatternOutputs( output, this, y, 112, -83, 0, y, 1 ) );
this.outputSlots[y].setRenderDisabled( false );
}
this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) );
@@ -184,7 +210,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
private ItemStack[] getInputs()
{
final ItemStack[] input = new ItemStack[16];
final ItemStack[] input = new ItemStack[CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES];
boolean hasValue = false;
for( int x = 0; x < this.craftingSlots.length; x++ )
@@ -206,7 +232,7 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
private ItemStack[] getOutputs()
{
final List<ItemStack> list = new ArrayList<>( 4 );
final List<ItemStack> list = new ArrayList<>( CRAFTING_GRID_SLOTS * CRAFTING_GRID_PAGES );
boolean hasValue = false;
for( final OptionalSlotFake outputSlot : this.outputSlots )
@@ -260,17 +286,14 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
@Override
public boolean isSlotEnabled( final int idx )
{
if( idx == 1 )
if (idx < 4) // outputs
{
Platform.isServer();
return true;
return inverted || idx == 0;
}
else if( idx == 2 )
else
{
Platform.isServer();
return false;
return !inverted || idx == 4;
}
return false;
}
@Override
@@ -280,6 +303,32 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
if( Platform.isServer() )
{
this.substitute = this.patternTerminal.isSubstitution();
if (inverted != patternTerminal.isInverted() || activePage != patternTerminal.getActivePage()) {
inverted = patternTerminal.isInverted();
activePage = patternTerminal.getActivePage();
offsetSlots();
}
}
}
private void offsetSlots()
{
for (int page = 0; page < CRAFTING_GRID_PAGES; page++) {
for (int y = 0; y < CRAFTING_GRID_HEIGHT; y++) {
for (int x = 0; x < CRAFTING_GRID_WIDTH; x++) {
this.craftingSlots[x + y * CRAFTING_GRID_WIDTH + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && inverted);
this.outputSlots[x * CRAFTING_GRID_HEIGHT + y + page * CRAFTING_GRID_SLOTS].setHidden(page != activePage || x > 0 && !inverted);
}
}
}
}
@Override
public void onUpdate(String field, Object oldValue, Object newValue) {
super.onUpdate( field, oldValue, newValue );
if (field.equals( "inverted" ) || field.equals( "activePage" )) {
offsetSlots();
}
}
@@ -288,13 +337,15 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
inverted = patternTerminal.isInverted();
for( final Object crafter : this.crafters )
{
final ICrafting icrafting = (ICrafting) crafter;
for( final Object g : this.inventorySlots )
{
if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
if( g instanceof OptionalSlotFake )
{
final Slot sri = (Slot) g;
icrafting.sendSlotContents( this, sri.slotNumber, sri.getStack() );
@@ -403,4 +454,12 @@ public class FCBasePartContainerEx extends FCBaseMonitorContain implements IAEAp
return fluid > 0;
}
public void setActivePage(final int activePage) {
this.activePage = activePage;
}
public int getActivePage() {
return this.activePage;
}
}
@@ -117,100 +117,54 @@ public class PartFluidPatternTerminal extends FCBasePart {
return GuiBridge.GUI_ME;
}
public void onChangeInventory0(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if( inv == this.pattern && slot == 1 )
{
final ItemStack is = this.pattern.getStackInSlot( 1 );
if( is != null && is.getItem() instanceof ICraftingPatternItem)
{
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setCraftingRecipe( details.isCraftable() );
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
}
}
else if( inv == this.crafting )
{
this.fixCraftingRecipes();
}
this.getHost().markForSave();
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ItemFluidEncodedPattern) {
final ItemFluidEncodedPattern pattern = (ItemFluidEncodedPattern) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setCraftingRecipe( details.isCraftable() );
this.setSubstitution( details.canSubstitute() );
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
this.setCraftingRecipe(details.isCraftable());
this.setSubstitution(details.canSubstitute());
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
for (int i = 0; i < this.output.getSizeInventory(); i++) {
this.output.setInventorySlotContents(i, null);
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(x, packet);
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
if (inItems[i] != null) {
final IAEItemStack item = inItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else
this.crafting.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
else this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(x, packet);
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
if (outItems[i] != null) {
final IAEItemStack item = outItems[i];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else
this.output.setInventorySlotContents(i, item == null ? null : item.getItemStack());
}
else this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
this.getHost().markForSave();
return;
}
}
onChangeInventory0(inv, slot, mc, removedStack, newStack);
this.getHost().markForSave();
}
private void fixCraftingRecipes()
@@ -11,7 +11,6 @@ import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
import com.glodblock.github.client.textures.FCPartsTexture;
import com.glodblock.github.common.item.ItemFluidDrop;
import com.glodblock.github.common.item.ItemFluidEncodedPattern;
import com.glodblock.github.common.item.ItemFluidPacket;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
@@ -34,11 +33,13 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
private static final FCPartsTexture FRONT_DARK_ICON = FCPartsTexture.PartFluidPatternTerminal_Colored;
private static final FCPartsTexture FRONT_COLORED_ICON = FCPartsTexture.PartFluidPatternTerminal_Dark;
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 16 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 4 );
private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, 32 );
private final AppEngInternalInventory output = new AppEngInternalInventory( this, 32 );
private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 );
private boolean substitute = false;
private boolean inverted = false;
private int activePage = 0;
public PartFluidPatternTerminalEx(ItemStack is) {
super(is, true);
@@ -78,20 +79,26 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
this.setSubstitution( data.getBoolean( "substitute" ) );
this.pattern.readFromNBT( data, "pattern" );
this.output.readFromNBT( data, "outputList" );
this.crafting.readFromNBT( data, "craftingGrid" );
this.setSubstitution( data.getBoolean( "substitute" ) );
this.setInverted( data.getBoolean( "inverted" ) );
this.setActivePage( data.getInteger( "activePage" ) );
}
@Override
public void writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setBoolean( "substitute", this.substitute );
this.pattern.writeToNBT( data, "pattern" );
this.output.writeToNBT( data, "outputList" );
this.crafting.writeToNBT( data, "craftingGrid" );
data.setBoolean( "substitute", this.substitute );
data.setBoolean( "inverted", this.inverted );
data.setInteger( "activePage", this.activePage );
}
@Override
@@ -114,94 +121,82 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
return GuiBridge.GUI_ME;
}
public void onChangeInventory0(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if( inv == this.pattern && slot == 1 )
{
final ItemStack is = this.pattern.getStackInSlot( 1 );
if( is != null && is.getItem() instanceof ICraftingPatternItem)
{
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
}
}
this.getHost().markForSave();
}
@Override
public void onChangeInventory(final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
if (inv == this.pattern && slot == 1) {
final ItemStack is = inv.getStackInSlot(1);
if (is != null && is.getItem() instanceof ItemFluidEncodedPattern) {
final ItemFluidEncodedPattern pattern = (ItemFluidEncodedPattern) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorldObj() );
if( details != null )
{
this.setSubstitution( details.canSubstitute() );
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
{
this.crafting.setInventorySlotContents( x, null );
}
if (is != null && is.getItem() instanceof ICraftingPatternItem) {
final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem();
final ICraftingPatternDetails details = pattern.getPatternForItem(is, this.getHost().getTile().getWorldObj());
for( int x = 0; x < this.output.getSizeInventory(); x++ )
{
this.output.setInventorySlotContents( x, null );
}
if (details != null) {
final IAEItemStack[] inItems = details.getInputs();
final IAEItemStack[] outItems = details.getOutputs();
int inputsCount = 0;
int outputCount = 0;
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
{
final IAEItemStack item = details.getInputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(x, packet);
for (int i = 0; i < inItems.length; i++) {
if (inItems[i] != null) {
inputsCount++;
}
else this.crafting.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
{
final IAEItemStack item = details.getOutputs()[x];
if (item != null && item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(x, packet);
for (int i = 0; i < outItems.length; i++) {
if (outItems[i] != null) {
outputCount++;
}
}
this.setSubstitution(details.canSubstitute());
this.setInverted(inputsCount <= 8 && outputCount >= 8);
this.setActivePage(0);
for (int i = 0; i < this.crafting.getSizeInventory(); i++) {
this.crafting.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.output.getSizeInventory(); i++) {
this.output.setInventorySlotContents(i, null);
}
for (int i = 0; i < this.crafting.getSizeInventory() && i < inItems.length; i++) {
final IAEItemStack item = inItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.crafting.setInventorySlotContents(i, packet);
} else this.crafting.setInventorySlotContents(i, item.getItemStack());
}
}
if (inverted) {
for (int i = 0; i < this.output.getSizeInventory() && i < outItems.length; i++) {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i, packet);
} else this.output.setInventorySlotContents(i, item.getItemStack());
}
}
} else {
for (int i = 0; i < outItems.length && i < 8; i++) {
final IAEItemStack item = outItems[i];
if (item != null) {
if (item.getItem() instanceof ItemFluidDrop) {
ItemStack packet = ItemFluidPacket.newStack(ItemFluidDrop.getFluidStack(item.getItemStack()));
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, packet);
} else
this.output.setInventorySlotContents(i >= 4 ? 12 + i : i, item.getItemStack());
}
}
else this.output.setInventorySlotContents( x, item == null ? null : item.getItemStack() );
}
}
this.getHost().markForSave();
return;
}
}
onChangeInventory0(inv, slot, mc, removedStack, newStack);
this.getHost().markForSave();
}
public boolean isSubstitution()
@@ -270,4 +265,20 @@ public class PartFluidPatternTerminalEx extends FCBasePart {
return false;
}
public boolean isInverted() {
return inverted;
}
public void setInverted(boolean inverted) {
this.inverted = inverted;
}
public int getActivePage() {
return this.activePage;
}
public void setActivePage(int activePage) {
this.activePage = activePage;
}
}
@@ -0,0 +1,17 @@
package com.glodblock.github.nei;
import codechicken.nei.api.INEIGuiAdapter;
import com.glodblock.github.client.gui.GuiFCBaseMonitor;
import net.minecraft.client.gui.inventory.GuiContainer;
public class NEIGuiHandler extends INEIGuiAdapter {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
if (gui instanceof GuiFCBaseMonitor) {
return ((GuiFCBaseMonitor) gui).hideItemPanelSlot(x, y, w, h);
}
return false;
}
}
@@ -11,6 +11,8 @@ public class NEI_FC_Config implements IConfigureNEI {
@Override
public void loadConfig() {
API.registerNEIGuiHandler(new NEIGuiHandler());
for (String identifier : FluidRecipe.getSupportRecipes()) {
API.registerGuiOverlayHandler(GuiFluidPatternTerminal.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier);
API.registerGuiOverlayHandler(GuiFluidPatternTerminalEx.class, FluidPatternTerminalRecipeTransferHandler.INSTANCE, identifier);
@@ -81,25 +81,31 @@ public class CPacketFluidPatternTermBtns implements IMessage {
cpt.doubleStacks(Value.equals("1"));
break;
}
} else if( Name.startsWith( "PatternTerminal." ) && (c instanceof ContainerFluidPatternTerminalEx))
} else if( Name.startsWith( "PatternTerminalEx." ) && (c instanceof ContainerFluidPatternTerminalEx))
{
final ContainerFluidPatternTerminalEx cpt = (ContainerFluidPatternTerminalEx) c;
switch (Name) {
case "PatternTerminal.Encode":
case "PatternTerminalEx.Encode":
if (Value.equals("2"))
cpt.encodeAndMoveToInventory();
else
cpt.encode();
break;
case "PatternTerminal.Clear":
case "PatternTerminalEx.Clear":
cpt.clear();
break;
case "PatternTerminal.Substitute":
case "PatternTerminalEx.Substitute":
cpt.getPatternTerminal().setSubstitution(Value.equals("1"));
break;
case "PatternTerminal.Double":
case "PatternTerminalEx.Invert":
cpt.getPatternTerminal().setInverted(Value.equals("1"));
break;
case "PatternTerminalEx.Double":
cpt.doubleStacks(Value.equals("1"));
break;
case "PatternTerminalEx.ActivePage":
cpt.getPatternTerminal().setActivePage(Integer.parseInt(Value));
break;
}
} else if(Name.equals( "Terminal.Cpu" ) && c instanceof ContainerFluidCraftConfirm) {
final ContainerFluidCraftConfirm qk = (ContainerFluidCraftConfirm) c;
@@ -24,7 +24,7 @@ public class CPacketTransferRecipe implements IMessage {
private List<OrderStack<?>> inputs;
private List<OrderStack<?>> outputs;
private boolean isCraft;
private final static int MAX_INDEX = 16;
private final static int MAX_INDEX = 32;
public CPacketTransferRecipe(){
}
@@ -11,6 +11,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.util.Constants;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
@@ -87,7 +88,9 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
if (condensed.length == 0) {
return false;
}
this.outputs = outputs;
this.outputs = Arrays.stream(outputs)
.filter(Objects::nonNull)
.toArray(IAEItemStack[]::new);
this.outputsCond = condensed;
return true;
}
@@ -159,12 +162,11 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
public static NBTTagList writeStackArray(IAEItemStack[] stacks) {
NBTTagList listTag = new NBTTagList();
for (IAEItemStack stack : stacks) {
if (stack != null) {
// see note at top of class
NBTTagCompound stackTag = new NBTTagCompound();
stack.writeToNBT(stackTag);
listTag.appendTag(stackTag);
}
// see note at top of class
NBTTagCompound stackTag = new NBTTagCompound();
if (stack != null) stack.writeToNBT(stackTag);
listTag.appendTag(stackTag);
}
return listTag;
}
@@ -176,13 +178,13 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
NBTTagCompound tag = Objects.requireNonNull(patternStack.getTagCompound());
// may be possible to enter a partially-correct state if setInputs succeeds but setOutputs failed
// but outside code should treat it as completely incorrect and not attempt to make calls
return setInputs(readStackArray(tag.getTagList("in", Constants.NBT.TAG_COMPOUND), 16))
&& setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND), 4));
return setInputs(readStackArray(tag.getTagList("in", Constants.NBT.TAG_COMPOUND)))
&& setOutputs(readStackArray(tag.getTagList("out", Constants.NBT.TAG_COMPOUND)));
}
public static IAEItemStack[] readStackArray(NBTTagList listTag, int maxCount) {
public static IAEItemStack[] readStackArray(NBTTagList listTag) {
// see note at top of class
IAEItemStack[] stacks = new IAEItemStack[Math.min(listTag.tagCount(), maxCount)];
IAEItemStack[] stacks = new IAEItemStack[listTag.tagCount()];
for (int i = 0; i < stacks.length; i++) {
stacks[i] = AEItemStack.loadItemStackFromNBT(listTag.getCompoundTagAt(i));
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 924 B