diff --git a/build.gradle b/build.gradle index 2dc7ef269..cddb93dbb 100644 --- a/build.gradle +++ b/build.gradle @@ -57,7 +57,7 @@ tasks.withType(JavaCompile) { options.encoding = 'UTF-8' } -version = aeversion + "-" + aechannel + "-" + aebuild + " " + trousers +version = trousers + "-" + aeversion + "-" + aechannel + "-" + aebuild + "-" + trousersversion group = aegroup archivesBaseName = aebasename diff --git a/gradle.properties b/gradle.properties index f91639e7c..ee6d5780e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,15 +3,14 @@ aechannel=stable aebuild=7 aegroup=appeng aebasename=appliedenergistics2 -trousers=omni-fixes-v49n - +trousers=trousers_edition +trousersversion=v49o ######################################################### # Versions # ######################################################### minecraft_version=1.12.2 mcp_mappings=snapshot_20171003 forge_version=14.23.5.2847 - ######################################################### # Installable # ######################################################### diff --git a/src/api/java/appeng/api/definitions/IParts.java b/src/api/java/appeng/api/definitions/IParts.java index 3b58f9c66..e0f04c483 100644 --- a/src/api/java/appeng/api/definitions/IParts.java +++ b/src/api/java/appeng/api/definitions/IParts.java @@ -102,6 +102,8 @@ public interface IParts IItemDefinition patternTerminal(); + IItemDefinition expandedProcessingPatternTerminal(); + IItemDefinition craftingTerminal(); IItemDefinition terminal(); diff --git a/src/main/java/appeng/client/gui/AEGuiHandler.java b/src/main/java/appeng/client/gui/AEGuiHandler.java index e525c3986..bfc78b519 100644 --- a/src/main/java/appeng/client/gui/AEGuiHandler.java +++ b/src/main/java/appeng/client/gui/AEGuiHandler.java @@ -104,7 +104,7 @@ public class AEGuiHandler implements IAdvancedGuiHandler, IGhostIngre } if( doStart && GuiScreen.isShiftKeyDown() && Mouse.isButtonDown( 0 ) ) { - if( gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm ) + if( gui instanceof GuiUpgradeable || gui instanceof GuiPatternTerm || gui instanceof GuiExpandedProcessingPatternTerm ) { IJEIGhostIngredients ghostGui = ( (IJEIGhostIngredients) gui ); for( Target target : targets ) diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java index 5babd6e4f..a6dd5f8ff 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftAmount.java @@ -21,6 +21,7 @@ package appeng.client.gui.implementations; import java.io.IOException; +import appeng.parts.reporting.PartExpandedProcessingPatternTerminal; import net.minecraft.client.gui.GuiButton; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -123,6 +124,12 @@ public class GuiCraftAmount extends AEBaseGui this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL; } + if( target instanceof PartExpandedProcessingPatternTerminal ) + { + myIcon = parts.expandedProcessingPatternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + this.originalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL; + } + if( this.originalGui != null && !myIcon.isEmpty() ) { this.buttonList.add( this.originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), this.itemRender ) ); diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java index bc15044f2..703c28024 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftConfirm.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import appeng.parts.reporting.PartExpandedProcessingPatternTerminal; import com.google.common.base.Joiner; import org.lwjgl.input.Mouse; @@ -104,6 +105,11 @@ public class GuiCraftConfirm extends AEBaseGui { this.OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL; } + + if( te instanceof PartExpandedProcessingPatternTerminal ) + { + this.OriginalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL; + } } boolean isAutoStart() diff --git a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java index b6257522b..2fc045110 100644 --- a/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java +++ b/src/main/java/appeng/client/gui/implementations/GuiCraftingStatus.java @@ -25,6 +25,7 @@ package appeng.client.gui.implementations; import java.io.IOException; +import appeng.parts.reporting.PartExpandedProcessingPatternTerminal; import org.lwjgl.input.Mouse; import net.minecraft.client.gui.GuiButton; @@ -95,6 +96,12 @@ public class GuiCraftingStatus extends GuiCraftingCPU this.originalGui = GuiBridge.GUI_PATTERN_TERMINAL; } + + if( target instanceof PartExpandedProcessingPatternTerminal ) + { + myIcon = parts.expandedProcessingPatternTerminal().maybeStack( 1 ).orElse( ItemStack.EMPTY ); + this.originalGui = GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL; + } } @Override diff --git a/src/main/java/appeng/client/gui/implementations/GuiExpandedProcessingPatternTerm.java b/src/main/java/appeng/client/gui/implementations/GuiExpandedProcessingPatternTerm.java new file mode 100644 index 000000000..2594b121f --- /dev/null +++ b/src/main/java/appeng/client/gui/implementations/GuiExpandedProcessingPatternTerm.java @@ -0,0 +1,277 @@ +package appeng.client.gui.implementations; + +import appeng.api.config.ActionItems; +import appeng.api.config.ItemSubstitution; +import appeng.api.config.Settings; +import appeng.api.storage.ITerminalHost; +import appeng.client.gui.widgets.GuiImgButton; +import appeng.client.gui.widgets.GuiTabButton; +import appeng.container.implementations.ContainerExpandedProcessingPatternTerm; +import appeng.container.interfaces.IJEIGhostIngredients; +import appeng.container.slot.AppEngSlot; +import appeng.container.slot.SlotFake; +import appeng.core.AELog; +import appeng.core.localization.GuiText; +import appeng.core.sync.network.NetworkHandler; +import appeng.core.sync.packets.PacketInventoryAction; +import appeng.core.sync.packets.PacketValueConfig; +import appeng.helpers.InventoryAction; +import appeng.util.item.AEItemStack; +import mezz.jei.api.gui.IGhostIngredientHandler; +import net.minecraft.client.gui.GuiButton; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +import java.awt.Rectangle; +import java.io.IOException; +import java.util.*; + + +public class GuiExpandedProcessingPatternTerm extends GuiMEMonitorable implements IJEIGhostIngredients +{ + private static final String BACKGROUND_EXPANDED_PROCESSING_MODE = "guis/pattern_processing_expanded.png"; + + private static final String SUBSITUTION_DISABLE = "0"; + private static final String SUBSITUTION_ENABLE = "1"; + + private static final String CRAFTMODE_CRFTING = "1"; + private static final String CRAFTMODE_PROCESSING = "0"; + + private GuiTabButton tabCraftButton; + private GuiTabButton tabProcessButton; + private GuiImgButton substitutionsEnabledBtn; + private GuiImgButton substitutionsDisabledBtn; + private GuiImgButton encodeBtn; + private GuiImgButton clearBtn; + private GuiImgButton x2Btn; + private GuiImgButton x3Btn; + private GuiImgButton plusOneBtn; + private GuiImgButton divTwoBtn; + private GuiImgButton divThreeBtn; + private GuiImgButton minusOneBtn; + private GuiImgButton maxCountBtn; + public Map, Object> mapTargetSlot = new HashMap<>(); + + public GuiExpandedProcessingPatternTerm( final InventoryPlayer inventoryPlayer, final ITerminalHost te ) + { + super( inventoryPlayer, te, new ContainerExpandedProcessingPatternTerm( inventoryPlayer, te ) ); + this.setReservedSpace( 81 ); + } + + @Override + protected void actionPerformed( final GuiButton btn ) + { + super.actionPerformed( btn ); + + try + { + + if( this.tabCraftButton == btn || this.tabProcessButton == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", this.tabProcessButton == btn ? CRAFTMODE_CRFTING : CRAFTMODE_PROCESSING ) ); + } + + if( this.encodeBtn == btn ) + { + if( isShiftKeyDown() ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "2" ) ); + } + else + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) ); + } + } + + if( this.clearBtn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) ); + } + + if( this.x2Btn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByTwo", "1" ) ); + } + + if( this.x3Btn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MultiplyByThree", "1" ) ); + } + + if( this.divTwoBtn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByTwo", "1" ) ); + } + + if( this.divThreeBtn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DivideByThree", "1" ) ); + } + + if( this.plusOneBtn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.IncreaseByOne", "1" ) ); + } + + if( this.minusOneBtn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.DecreaseByOne", "1" ) ); + } + + if( this.maxCountBtn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.MaximizeCount", "1" ) ); + } + + if( this.substitutionsEnabledBtn == btn || this.substitutionsDisabledBtn == btn ) + { + NetworkHandler.instance().sendToServer( new PacketValueConfig( "PatternTerminal.Substitute", this.substitutionsEnabledBtn == btn ? SUBSITUTION_DISABLE : SUBSITUTION_ENABLE ) ); + } + } + catch( final IOException e ) + { + AELog.error( e ); + } + } + + @Override + public void initGui() + { + super.initGui(); + + this.tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.CRAFTING_TABLE ), GuiText.CraftingPattern.getLocal(), this.itemRender ); + this.buttonList.add( this.tabCraftButton ); + + this.tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.FURNACE ), GuiText.ProcessingPattern.getLocal(), this.itemRender ); + this.buttonList.add( this.tabProcessButton ); + + this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED ); + this.substitutionsEnabledBtn.setHalfSize( true ); + this.buttonList.add( this.substitutionsEnabledBtn ); + + this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED ); + this.substitutionsDisabledBtn.setHalfSize( true ); + this.buttonList.add( this.substitutionsDisabledBtn ); + + this.clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ); + this.clearBtn.setHalfSize( true ); + this.buttonList.add( this.clearBtn ); + + this.x3Btn = new GuiImgButton( this.guiLeft + 131, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.MULTIPLY_BY_THREE ); + this.x3Btn.setHalfSize( true ); + this.buttonList.add( this.x3Btn ); + + this.x2Btn = new GuiImgButton( this.guiLeft + 131, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.MULTIPLY_BY_TWO ); + this.x2Btn.setHalfSize( true ); + this.buttonList.add( this.x2Btn ); + + this.plusOneBtn = new GuiImgButton( this.guiLeft + 131, this.guiTop + this.ySize - 110, Settings.ACTIONS, ActionItems.INCREASE_BY_ONE ); + this.plusOneBtn.setHalfSize( true ); + this.buttonList.add( this.plusOneBtn ); + + this.divThreeBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 158, Settings.ACTIONS, ActionItems.DIVIDE_BY_THREE ); + this.divThreeBtn.setHalfSize( true ); + this.buttonList.add( this.divThreeBtn ); + + this.divTwoBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 148, Settings.ACTIONS, ActionItems.DIVIDE_BY_TWO ); + this.divTwoBtn.setHalfSize( true ); + this.buttonList.add( this.divTwoBtn ); + + this.minusOneBtn = new GuiImgButton( this.guiLeft + 87, this.guiTop + this.ySize - 110, Settings.ACTIONS, ActionItems.DECREASE_BY_ONE ); + this.minusOneBtn.setHalfSize( true ); + this.buttonList.add( this.minusOneBtn ); + + //this.maxCountBtn = new GuiImgButton( this.guiLeft + 128, this.guiTop + this.ySize - 108, Settings.ACTIONS, ActionItems.MAX_COUNT ); + //this.maxCountBtn.setHalfSize( true ); + //this.buttonList.add( this.maxCountBtn ); + + this.encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ); + this.buttonList.add( this.encodeBtn ); + } + + @Override + public void drawFG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) + { + this.tabCraftButton.visible = false; + this.tabProcessButton.visible = true; + this.substitutionsEnabledBtn.visible = false; + this.substitutionsDisabledBtn.visible = false; + this.x2Btn.visible = true; + this.x3Btn.visible = true; + this.divTwoBtn.visible = true; + this.divThreeBtn.visible = true; + this.plusOneBtn.visible = true; + this.minusOneBtn.visible = true; + //this.maxCountBtn.visible = true; + + super.drawFG( offsetX, offsetY, mouseX, mouseY ); + this.fontRenderer.drawString( GuiText.PatternTerminal.getLocal(), 8, this.ySize - 96 + 2 - this.getReservedSpace(), 4210752 ); + } + + @Override + protected String getBackground() + { + return BACKGROUND_EXPANDED_PROCESSING_MODE; + } + + @Override + protected void repositionSlot( final AppEngSlot s ) + { + final int offsetPlayerSide = s.isPlayerSide() ? 5 : 3; + + s.yPos = s.getY() + this.ySize - 78 - offsetPlayerSide; + } + + @Override + public List> getPhantomTargets( Object ingredient ) + { + if( !( ingredient instanceof ItemStack ) ) + { + return Collections.emptyList(); + } + List> targets = new ArrayList<>(); + for( Slot slot : this.inventorySlots.inventorySlots ) + { + if( slot instanceof SlotFake ) + { + ItemStack itemStack = (ItemStack) ingredient; + IGhostIngredientHandler.Target target = new IGhostIngredientHandler.Target() + { + @Override + public Rectangle getArea() + { + return new Rectangle( getGuiLeft() + slot.xPos, getGuiTop() + slot.yPos, 16, 16 ); + } + + @Override + public void accept( Object ingredient ) + { + final PacketInventoryAction p; + try + { + p = new PacketInventoryAction( InventoryAction.PLACE_JEI_GHOST_ITEM, (SlotFake) slot, AEItemStack.fromItemStack( itemStack ) ); + NetworkHandler.instance().sendToServer( p ); + + } + catch( IOException e ) + { + e.printStackTrace(); + } + } + }; + targets.add( target ); + mapTargetSlot.putIfAbsent( target, slot ); + } + } + return targets; + } + + @Override + public Map, Object> getFakeSlotTargetMap() + { + return mapTargetSlot; + } +} + diff --git a/src/main/java/appeng/container/implementations/ContainerExpandedProcessingPatternTerm.java b/src/main/java/appeng/container/implementations/ContainerExpandedProcessingPatternTerm.java new file mode 100644 index 000000000..fc615a0d8 --- /dev/null +++ b/src/main/java/appeng/container/implementations/ContainerExpandedProcessingPatternTerm.java @@ -0,0 +1,528 @@ +package appeng.container.implementations; + +import appeng.api.AEApi; +import appeng.api.definitions.IDefinitions; +import appeng.api.storage.ITerminalHost; +import appeng.container.slot.*; +import appeng.helpers.IContainerCraftingPacket; +import appeng.parts.reporting.PartExpandedProcessingPatternTerminal; +import appeng.util.Platform; +import appeng.util.inv.IAEAppEngInventory; +import appeng.util.inv.InvOperation; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTBase; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.items.IItemHandler; +import net.minecraftforge.items.wrapper.PlayerInvWrapper; + +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; + +import static appeng.helpers.PatternHelper.PROCESSING_INPUT_LIMIT; +import static appeng.helpers.PatternHelper.PROCESSING_OUTPUT_LIMIT; + + +public class ContainerExpandedProcessingPatternTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IOptionalSlotHost, IContainerCraftingPacket +{ + private final IItemHandler crafting; + private final SlotFakeCraftingMatrix[] gridSlots = new SlotFakeCraftingMatrix[PROCESSING_INPUT_LIMIT]; + private final OptionalSlotFake[] outputSlots = new OptionalSlotFake[PROCESSING_OUTPUT_LIMIT]; + private final SlotRestrictedInput patternSlotIN; + private final SlotRestrictedInput patternSlotOUT; + private final PartExpandedProcessingPatternTerminal expandedProcessingPatternTerminal; + + public ContainerExpandedProcessingPatternTerm( InventoryPlayer ip, ITerminalHost monitorable ) + { + super( ip, monitorable, false ); + + this.expandedProcessingPatternTerminal = (PartExpandedProcessingPatternTerminal) monitorable; + + final IItemHandler patternInv = this.getExpandedPatternTerminal().getInventoryByName( "pattern" ); + final IItemHandler output = this.getExpandedPatternTerminal().getInventoryByName( "output" ); + + this.crafting = this.getExpandedPatternTerminal().getInventoryByName( "crafting" ); + + for( int y = 0; y < 4; y++ ) + { + for( int x = 0; x < 4; x++ ) + { + this.addSlotToContainer( this.gridSlots[x + y * 4] = new SlotFakeCraftingMatrix( this.crafting, x + y * 4, 4 + x * 18, -85 + y * 18 ) ); + } + } + + for( int y = 0; y < 3; y++ ) + { + for( int x = 0; x < 2; x++ ) + { + this.addSlotToContainer( this.outputSlots[x + y * 2] = new SlotPatternOutputs( output, this, x + y * 2, 96 + x * 18, -76 + y * 18, 0, 0, 1 ) ); + this.outputSlots[x + y * 2].setRenderDisabled( false ); + this.outputSlots[x + y * 2].setIIcon( -1 ); + } + } + + this.addSlotToContainer( this.patternSlotIN = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.BLANK_PATTERN, patternInv, 0, 147, -72 - 9, this.getInventoryPlayer() ) ); + this.addSlotToContainer( this.patternSlotOUT = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ENCODED_PATTERN, patternInv, 1, 147, -72 + 34, this.getInventoryPlayer() ) ); + + this.patternSlotOUT.setStackLimit( 1 ); + + this.bindPlayerInventory( ip, 0, 0 ); + } + + @Override + public ItemStack transferStackInSlot( final EntityPlayer p, final int idx ) + { + if( Platform.isClient() ) + { + return ItemStack.EMPTY; + } + if( this.inventorySlots.get( idx ) instanceof SlotPlayerInv || this.inventorySlots.get( idx ) instanceof SlotPlayerHotBar ) + { + final AppEngSlot clickSlot = (AppEngSlot) this.inventorySlots.get( idx ); // require AE SLots! + ItemStack itemStack = clickSlot.getStack(); + if( AEApi.instance().definitions().materials().blankPattern().isSameAs( itemStack ) ) + { + IItemHandler patternInv = this.getExpandedPatternTerminal().getInventoryByName( "pattern" ); + ItemStack remainder = patternInv.insertItem( 0, itemStack, false ); + clickSlot.putStack( remainder ); + } + } + return super.transferStackInSlot( p, idx ); + } + + @Override + public void saveChanges() + { + + } + + @Override + public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack ) + { + + } + + public void encodeAndMoveToInventory() + { + encode(); + ItemStack output = this.patternSlotOUT.getStack(); + if( !output.isEmpty() ) + { + if( !getPlayerInv().addItemStackToInventory( output ) ) + { + getPlayerInv().player.dropItem( output, false ); + } + this.patternSlotOUT.putStack( ItemStack.EMPTY ); + } + } + + public void encode() + { + ItemStack output = this.patternSlotOUT.getStack(); + + final ItemStack[] in = this.getInputs(); + final ItemStack[] out = this.getOutputs(); + + // if there is no input, this would be silly. + if( in == null || out == null ) + { + return; + } + + // first check the output slots, should either be null, or a pattern + if( !output.isEmpty() && !this.isPattern( output ) ) + { + return; + } // if nothing is there we should snag a new pattern. + else if( output.isEmpty() ) + { + output = this.patternSlotIN.getStack(); + if( output.isEmpty() || !this.isPattern( output ) ) + { + return; // no blanks. + } + + // remove one, and clear the input slot. + output.setCount( output.getCount() - 1 ); + if( output.getCount() == 0 ) + { + this.patternSlotIN.putStack( ItemStack.EMPTY ); + } + + // add a new encoded pattern. + Optional maybePattern = AEApi.instance().definitions().items().encodedPattern().maybeStack( 1 ); + if( maybePattern.isPresent() ) + { + output = maybePattern.get(); + this.patternSlotOUT.putStack( output ); + } + } + + // encode the slot. + final NBTTagCompound encodedValue = new NBTTagCompound(); + + final NBTTagList tagIn = new NBTTagList(); + final NBTTagList tagOut = new NBTTagList(); + + for( final ItemStack i : in ) + { + tagIn.appendTag( this.createItemTag( i ) ); + } + + for( final ItemStack i : out ) + { + tagOut.appendTag( this.createItemTag( i ) ); + } + + encodedValue.setTag( "in", tagIn ); + encodedValue.setTag( "out", tagOut ); + encodedValue.setBoolean( "crafting", false ); + encodedValue.setBoolean( "substitute", false ); + + output.setTagCompound( encodedValue ); + } + + boolean isPattern( final ItemStack output ) + { + if( output.isEmpty() ) + { + return false; + } + + final IDefinitions definitions = AEApi.instance().definitions(); + + boolean isPattern = definitions.items().encodedPattern().isSameAs( output ); + isPattern |= definitions.materials().blankPattern().isSameAs( output ); + + return isPattern; + } + + NBTBase createItemTag( final ItemStack i ) + { + final NBTTagCompound c = new NBTTagCompound(); + + if( !i.isEmpty() ) + { + i.writeToNBT( c ); + } + + return c; + } + + @Override + public boolean isSlotEnabled( final int idx ) + { + return true; + } + + protected ItemStack[] getInputs() + { + final ItemStack[] input = new ItemStack[16]; + boolean hasValue = false; + + for( int x = 0; x < this.gridSlots.length; x++ ) + { + input[x] = this.gridSlots[x].getStack(); + if( !input[x].isEmpty() ) + { + hasValue = true; + } + } + + if( hasValue ) + { + return input; + } + + return null; + } + + protected ItemStack[] getOutputs() + { + final List list = new ArrayList<>( 3 ); + boolean hasValue = false; + + for( final OptionalSlotFake outputSlot : this.outputSlots ) + { + final ItemStack out = outputSlot.getStack(); + + if( !out.isEmpty() && out.getCount() > 0 ) + { + list.add( out ); + hasValue = true; + } + } + + if( hasValue ) + { + return list.toArray( new ItemStack[0] ); + } + return null; + } + + public void clear() + { + for( final Slot s : this.gridSlots ) + { + s.putStack( ItemStack.EMPTY ); + } + + for( final Slot s : this.outputSlots ) + { + s.putStack( ItemStack.EMPTY ); + } + + this.detectAndSendChanges(); + } + + @Override + public IItemHandler getInventoryByName( final String name ) + { + if( name.equals( "player" ) ) + { + return new PlayerInvWrapper( this.getInventoryPlayer() ); + } + return this.getExpandedPatternTerminal().getInventoryByName( name ); + } + + @Override + public boolean useRealItems() + { + return false; + } + + public PartExpandedProcessingPatternTerminal getExpandedPatternTerminal() + { + return this.expandedProcessingPatternTerminal; + } + + public void multiply( int multiple ) + { + ItemStack[] input = new ItemStack[gridSlots.length]; + boolean canMultiplyInputs = true; + boolean canMultiplyOutputs = true; + + for( int x = 0; x < this.gridSlots.length; x++ ) + { + input[x] = this.gridSlots[x].getStack(); + if( !input[x].isEmpty() && input[x].getCount() * multiple > input[x].getMaxStackSize() ) + { + canMultiplyInputs = false; + } + } + for( final OptionalSlotFake outputSlot : this.outputSlots ) + { + final ItemStack out = outputSlot.getStack(); + if( !out.isEmpty() && out.getCount() * multiple > out.getMaxStackSize() ) + { + canMultiplyOutputs = false; + } + } + if( canMultiplyInputs && canMultiplyOutputs ) + { + for( SlotFakeCraftingMatrix craftingSlot : this.gridSlots ) + { + ItemStack stack = craftingSlot.getStack(); + if( !stack.isEmpty() ) + { + craftingSlot.getStack().setCount( stack.getCount() * multiple ); + } + } + for( OptionalSlotFake outputSlot : this.outputSlots ) + { + ItemStack stack = outputSlot.getStack(); + if( !stack.isEmpty() ) + { + outputSlot.getStack().setCount( stack.getCount() * multiple ); + } + } + } + } + + public void divide( int divide ) + { + ItemStack[] input = new ItemStack[gridSlots.length]; + boolean canDivideInputs = true; + boolean canDivideOutputs = true; + + for( int x = 0; x < this.gridSlots.length; x++ ) + { + input[x] = this.gridSlots[x].getStack(); + if( !input[x].isEmpty() && input[x].getCount() % divide != 0 ) + { + canDivideInputs = false; + } + } + for( final OptionalSlotFake outputSlot : this.outputSlots ) + { + final ItemStack out = outputSlot.getStack(); + if( !out.isEmpty() && out.getCount() % divide != 0 ) + { + canDivideOutputs = false; + } + } + if( canDivideInputs && canDivideOutputs ) + { + for( SlotFakeCraftingMatrix craftingSlot : this.gridSlots ) + { + ItemStack stack = craftingSlot.getStack(); + if( !stack.isEmpty() ) + { + craftingSlot.getStack().setCount( stack.getCount() / divide ); + } + } + for( OptionalSlotFake outputSlot : this.outputSlots ) + { + ItemStack stack = outputSlot.getStack(); + if( !stack.isEmpty() ) + { + outputSlot.getStack().setCount( stack.getCount() / divide ); + } + } + } + } + + public void increase( int increase ) + { + ItemStack[] input = new ItemStack[gridSlots.length]; + boolean canIncreaseInputs = true; + boolean canIncreaseOutputs = true; + + for( int x = 0; x < this.gridSlots.length; x++ ) + { + input[x] = this.gridSlots[x].getStack(); + if( !input[x].isEmpty() && input[x].getCount() + increase > input[x].getMaxStackSize() ) + { + canIncreaseInputs = false; + } + } + for( final OptionalSlotFake outputSlot : this.outputSlots ) + { + final ItemStack out = outputSlot.getStack(); + if( !out.isEmpty() && out.getCount() + increase > out.getMaxStackSize() ) + { + canIncreaseOutputs = false; + } + } + if( canIncreaseInputs && canIncreaseOutputs ) + { + for( SlotFakeCraftingMatrix craftingSlot : this.gridSlots ) + { + ItemStack stack = craftingSlot.getStack(); + if( !stack.isEmpty() ) + { + craftingSlot.getStack().setCount( stack.getCount() + increase ); + } + } + for( OptionalSlotFake outputSlot : this.outputSlots ) + { + ItemStack stack = outputSlot.getStack(); + if( !stack.isEmpty() ) + { + outputSlot.getStack().setCount( stack.getCount() + increase ); + } + } + } + } + + public void decrease( int decrease ) + { + ItemStack[] input = new ItemStack[gridSlots.length]; + boolean canDecreaseInputs = true; + boolean canDecreaseOutputs = true; + + for( int x = 0; x < this.gridSlots.length; x++ ) + { + input[x] = this.gridSlots[x].getStack(); + if( !input[x].isEmpty() && input[x].getCount() - decrease < 1 ) + { + canDecreaseInputs = false; + } + } + for( final OptionalSlotFake outputSlot : this.outputSlots ) + { + final ItemStack out = outputSlot.getStack(); + if( !out.isEmpty() && out.getCount() - decrease < 1 ) + { + canDecreaseOutputs = false; + } + } + if( canDecreaseInputs && canDecreaseOutputs ) + { + for( SlotFakeCraftingMatrix craftingSlot : this.gridSlots ) + { + ItemStack stack = craftingSlot.getStack(); + if( !stack.isEmpty() ) + { + craftingSlot.getStack().setCount( stack.getCount() - decrease ); + } + } + for( OptionalSlotFake outputSlot : this.outputSlots ) + { + ItemStack stack = outputSlot.getStack(); + if( !stack.isEmpty() ) + { + outputSlot.getStack().setCount( stack.getCount() - decrease ); + } + } + } + } + + public void maximizeCount() + { + ItemStack[] input = new ItemStack[gridSlots.length]; + boolean canGrowInputs = true; + boolean canGrowOutputs = true; + int maxInputStackGrowth = 0; + int maxOutputStackGrowth = 0; + + for( int x = 0; x < this.gridSlots.length; x++ ) + { + input[x] = this.gridSlots[x].getStack(); + if( !input[x].isEmpty() && input[x].getMaxStackSize() - input[x].getCount() > maxInputStackGrowth ) + { + maxInputStackGrowth = input[x].getMaxStackSize() - input[x].getCount(); + } + if( !input[x].isEmpty() && input[x].getCount() + maxInputStackGrowth > input[x].getMaxStackSize() ) + { + canGrowInputs = false; + } + } + for( final OptionalSlotFake outputSlot : this.outputSlots ) + { + final ItemStack out = outputSlot.getStack(); + { + maxOutputStackGrowth = out.getMaxStackSize() - out.getCount(); + } + if( !out.isEmpty() && out.getCount() + maxOutputStackGrowth > out.getMaxStackSize() ) + { + canGrowOutputs = false; + } + } + if( canGrowInputs && canGrowOutputs ) + { + int maxStackGrowth = Math.min( maxInputStackGrowth, maxOutputStackGrowth ); + for( SlotFakeCraftingMatrix craftingSlot : this.gridSlots ) + { + ItemStack stack = craftingSlot.getStack(); + if( !stack.isEmpty() ) + { + craftingSlot.getStack().setCount( stack.getCount() + maxStackGrowth ); + } + } + for( OptionalSlotFake outputSlot : this.outputSlots ) + { + ItemStack stack = outputSlot.getStack(); + if( !stack.isEmpty() ) + { + outputSlot.getStack().setCount( stack.getCount() + maxStackGrowth ); + } + } + } + } + +} diff --git a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java index daa615baf..ff7e00a43 100644 --- a/src/main/java/appeng/container/implementations/ContainerPatternTerm.java +++ b/src/main/java/appeng/container/implementations/ContainerPatternTerm.java @@ -178,7 +178,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA this.getAndUpdateOutput(); } - private ItemStack getAndUpdateOutput() + protected ItemStack getAndUpdateOutput() { final World world = this.getPlayerInv().player.world; final InventoryCrafting ic = new InventoryCrafting( this, 3, 3 ); @@ -505,7 +505,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA } } - private ItemStack[] getInputs() + protected ItemStack[] getInputs() { final ItemStack[] input = new ItemStack[9]; boolean hasValue = false; @@ -527,7 +527,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA return null; } - private ItemStack[] getOutputs() + protected ItemStack[] getOutputs() { if( this.isCraftingMode() ) { @@ -535,7 +535,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA if( !out.isEmpty() && out.getCount() > 0 ) { - return new ItemStack[] { out }; + return new ItemStack[]{out}; } } else @@ -563,7 +563,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA return null; } - private boolean isPattern( final ItemStack output ) + boolean isPattern( final ItemStack output ) { if( output.isEmpty() ) { @@ -578,7 +578,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA return isPattern; } - private NBTBase createItemTag( final ItemStack i ) + NBTBase createItemTag( final ItemStack i ) { final NBTTagCompound c = new NBTTagCompound(); @@ -824,7 +824,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA return this.patternTerminal; } - private boolean isSubstitute() + boolean isSubstitute() { return this.substitute; } diff --git a/src/main/java/appeng/core/api/definitions/ApiParts.java b/src/main/java/appeng/core/api/definitions/ApiParts.java index b4ef20b1e..6b11ec4a4 100644 --- a/src/main/java/appeng/core/api/definitions/ApiParts.java +++ b/src/main/java/appeng/core/api/definitions/ApiParts.java @@ -77,6 +77,7 @@ public final class ApiParts implements IParts private final IItemDefinition darkMonitor; private final IItemDefinition interfaceTerminal; private final IItemDefinition patternTerminal; + private final IItemDefinition expandedProcessingPatternTerminal; private final IItemDefinition craftingTerminal; private final IItemDefinition terminal; private final IItemDefinition storageMonitor; @@ -139,6 +140,7 @@ public final class ApiParts implements IParts this.darkMonitor = new DamagedItemDefinition( "part.monitor.dark", itemPart.createPart( PartType.DARK_MONITOR ) ); this.interfaceTerminal = new DamagedItemDefinition( "part.terminal.interface", itemPart.createPart( PartType.INTERFACE_TERMINAL ) ); this.patternTerminal = new DamagedItemDefinition( "part.terminal.pattern", itemPart.createPart( PartType.PATTERN_TERMINAL ) ); + this.expandedProcessingPatternTerminal = new DamagedItemDefinition( "part.terminal.expanded_processing_pattern", itemPart.createPart( PartType.EXPANDED_PROCESSING_PATTERN_TERMINAL ) ); this.craftingTerminal = new DamagedItemDefinition( "part.terminal.crafting", itemPart.createPart( PartType.CRAFTING_TERMINAL ) ); this.terminal = new DamagedItemDefinition( "part.terminal", itemPart.createPart( PartType.TERMINAL ) ); this.storageMonitor = new DamagedItemDefinition( "part.monitor.storage", itemPart.createPart( PartType.STORAGE_MONITOR ) ); @@ -379,6 +381,12 @@ public final class ApiParts implements IParts return this.patternTerminal; } + @Override + public IItemDefinition expandedProcessingPatternTerminal() + { + return this.expandedProcessingPatternTerminal; + } + @Override public IItemDefinition craftingTerminal() { diff --git a/src/main/java/appeng/core/sync/GuiBridge.java b/src/main/java/appeng/core/sync/GuiBridge.java index 8cecd7f45..f2febfb20 100644 --- a/src/main/java/appeng/core/sync/GuiBridge.java +++ b/src/main/java/appeng/core/sync/GuiBridge.java @@ -21,6 +21,8 @@ package appeng.core.sync; import java.lang.reflect.Constructor; +import appeng.container.implementations.*; +import appeng.parts.reporting.PartExpandedProcessingPatternTerminal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.item.ItemStack; @@ -53,39 +55,6 @@ import appeng.client.gui.GuiNull; import appeng.container.AEBaseContainer; import appeng.container.ContainerNull; import appeng.container.ContainerOpenContext; -import appeng.container.implementations.ContainerCellWorkbench; -import appeng.container.implementations.ContainerChest; -import appeng.container.implementations.ContainerCondenser; -import appeng.container.implementations.ContainerCraftAmount; -import appeng.container.implementations.ContainerCraftConfirm; -import appeng.container.implementations.ContainerCraftingCPU; -import appeng.container.implementations.ContainerCraftingStatus; -import appeng.container.implementations.ContainerCraftingTerm; -import appeng.container.implementations.ContainerDrive; -import appeng.container.implementations.ContainerFormationPlane; -import appeng.container.implementations.ContainerGrinder; -import appeng.container.implementations.ContainerIOPort; -import appeng.container.implementations.ContainerInscriber; -import appeng.container.implementations.ContainerInterface; -import appeng.container.implementations.ContainerInterfaceTerminal; -import appeng.container.implementations.ContainerLevelEmitter; -import appeng.container.implementations.ContainerMAC; -import appeng.container.implementations.ContainerMEMonitorable; -import appeng.container.implementations.ContainerMEPortableCell; -import appeng.container.implementations.ContainerNetworkStatus; -import appeng.container.implementations.ContainerNetworkTool; -import appeng.container.implementations.ContainerPatternTerm; -import appeng.container.implementations.ContainerPriority; -import appeng.container.implementations.ContainerQNB; -import appeng.container.implementations.ContainerQuartzKnife; -import appeng.container.implementations.ContainerSecurityStation; -import appeng.container.implementations.ContainerSkyChest; -import appeng.container.implementations.ContainerSpatialIOPort; -import appeng.container.implementations.ContainerStorageBus; -import appeng.container.implementations.ContainerUpgradeable; -import appeng.container.implementations.ContainerVibrationChamber; -import appeng.container.implementations.ContainerWireless; -import appeng.container.implementations.ContainerWirelessTerm; import appeng.fluids.container.ContainerFluidFormationPlane; import appeng.fluids.container.ContainerFluidIO; import appeng.fluids.container.ContainerFluidInterface; @@ -185,6 +154,8 @@ public enum GuiBridge implements IGuiHandler GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ), + GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL( ContainerExpandedProcessingPatternTerm.class, PartExpandedProcessingPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ), + GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, ITerminalHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ), // extends (Container/Gui) + Bus diff --git a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java index 0aeedd7f7..2e05dfbe7 100644 --- a/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java +++ b/src/main/java/appeng/core/sync/packets/PacketJEIRecipe.java @@ -23,11 +23,12 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; +import java.util.ArrayList; import java.util.Collection; -import java.util.Iterator; +import java.util.List; import appeng.api.config.FuzzyMode; -import appeng.api.storage.data.IItemList; +import appeng.container.implementations.ContainerExpandedProcessingPatternTerm; import appeng.container.implementations.ContainerPatternTerm; import gregtech.common.items.MetaTool; import io.netty.buffer.ByteBuf; @@ -69,8 +70,9 @@ import appeng.util.prioritylist.IPartitionList; public class PacketJEIRecipe extends AppEngPacket { - private ItemStack[][] recipe; - private ItemStack[] output; + private List recipe; + private List output; + static ItemStack[] emptyArray = {ItemStack.EMPTY}; // automatic. @@ -81,28 +83,35 @@ public class PacketJEIRecipe extends AppEngPacket final NBTTagCompound comp = CompressedStreamTools.readCompressed( bytes ); if( comp != null ) { - this.recipe = new ItemStack[9][]; - for( int x = 0; x < this.recipe.length; x++ ) + this.recipe = new ArrayList<>(); + + for( int x = 0; x < comp.getKeySet().size(); x++ ) { - final NBTTagList list = comp.getTagList( "#" + x, 10 ); - if( list.tagCount() > 0 ) + if( comp.hasKey( "#" + x ) ) { - this.recipe[x] = new ItemStack[list.tagCount()]; - for( int y = 0; y < list.tagCount(); y++ ) + final NBTTagList list = comp.getTagList( "#" + x, 10 ); + if( list.tagCount() > 0 ) { - this.recipe[x][y] = new ItemStack( list.getCompoundTagAt( y ) ); + this.recipe.add( new ItemStack[list.tagCount()] ); + for( int y = 0; y < list.tagCount(); y++ ) + { + this.recipe.get( x )[y] = new ItemStack( list.getCompoundTagAt( y ) ); + } + } + else + { + this.recipe.add( emptyArray ); } } } - if ( comp.hasKey("outputs") ) { - final NBTTagList outputList = comp.getTagList("outputs", 10); - this.output = new ItemStack[3]; - for( int x = 0; x < this.output.length; x++ ) + + if( comp.hasKey( "outputs" ) ) + { + final NBTTagList outputList = comp.getTagList( "outputs", 10 ); + this.output = new ArrayList<>(); + for( int z = 0; z < outputList.tagCount(); z++ ) { - if( outputList.tagCount() > 0 ) - { - this.output[x] = new ItemStack(outputList.getCompoundTagAt( x )); - } + this.output.add( new ItemStack( outputList.getCompoundTagAt( z ) ) ); } } } @@ -172,9 +181,12 @@ public class PacketJEIRecipe extends AppEngPacket // already the correct item? ItemStack newItem = this.canUseInSlot( x, currentItem ); - if ( !cct.useRealItems() && this.recipe[x] != null ) { - if (this.recipe[x].length > 0 ) - currentItem.setCount( recipe[x][0].getCount() ); + if( !cct.useRealItems() && this.recipe.get( x ) != null ) + { + if( this.recipe.get( x ).length > 0 ) + { + currentItem.setCount( recipe.get( x )[0].getCount() ); + } } // put away old item @@ -193,12 +205,12 @@ public class PacketJEIRecipe extends AppEngPacket } } - if( currentItem.isEmpty() && this.recipe[x] != null ) + if( currentItem.isEmpty() && recipe.size() > x && recipe.get( x ) != null ) { // for each variant - for( int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++ ) + for( int y = 0; y < this.recipe.get( x ).length && currentItem.isEmpty(); y++ ) { - final IAEItemStack request = AEItemStack.fromItemStack( this.recipe[x][y] ); + final IAEItemStack request = AEItemStack.fromItemStack( this.recipe.get( x )[y] ); if( request != null ) { // try ae @@ -247,7 +259,7 @@ public class PacketJEIRecipe extends AppEngPacket { if (!cct.useRealItems()) { - out.setStackSize( recipe[x][y].getCount() ); + out.setStackSize( recipe.get( x )[y].getCount() ); } currentItem = out.createItemStack(); } @@ -260,20 +272,20 @@ public class PacketJEIRecipe extends AppEngPacket if( cct.useRealItems() ) { - currentItem = ad.removeSimilarItems(1, this.recipe[x][y],FuzzyMode.IGNORE_ALL, null ); + currentItem = ad.removeSimilarItems( 1, this.recipe.get( x )[y], FuzzyMode.IGNORE_ALL, null ); } else { - currentItem = ad.simulateSimilarRemove(recipe[x][y].getCount(), this.recipe[x][y],FuzzyMode.IGNORE_ALL, null ); + currentItem = ad.simulateSimilarRemove( recipe.get( x )[y].getCount(), this.recipe.get( x )[y], FuzzyMode.IGNORE_ALL, null ); } } } } if (!cct.useRealItems()) { - if( currentItem.isEmpty() && this.recipe[x] != null ) + if( currentItem.isEmpty() && recipe.size() > x && this.recipe.get( x ) != null ) { - currentItem = this.recipe[x][0].copy(); + currentItem = this.recipe.get( x )[0].copy(); } } } @@ -282,14 +294,19 @@ public class PacketJEIRecipe extends AppEngPacket con.onCraftMatrixChanged( new WrapperInvItemHandler( craftMatrix ) ); - if( this.output != null && con instanceof ContainerPatternTerm && !( (ContainerPatternTerm) con ).isCraftingMode() ) + if( this.output != null && ( ( con instanceof ContainerPatternTerm && !( (ContainerPatternTerm) con ).isCraftingMode() ) || con instanceof ContainerExpandedProcessingPatternTerm ) ) { IItemHandler outputSlots = cct.getInventoryByName( "output" ); - for( int i = 0; i < this.output.length; ++i ) + + for( int i = 0; i < this.output.size(); ++i ) { - if( this.output[i] == null ) continue; - ItemHandlerUtil.setStackInSlot( outputSlots, i, this.output[i] ); + if( this.output.get( i ) == null ) + { + continue; + } + ItemHandlerUtil.setStackInSlot( outputSlots, i, this.output.get( i ) ); } + } } } @@ -302,9 +319,9 @@ public class PacketJEIRecipe extends AppEngPacket */ private ItemStack canUseInSlot( int slot, ItemStack is ) { - if( this.recipe[slot] != null ) + if( this.recipe.get( slot ) != null ) { - for( ItemStack option : this.recipe[slot] ) + for( ItemStack option : this.recipe.get( slot ) ) { if( ItemStack.areItemStacksEqual( is, option ) ) { diff --git a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java index 9601e6daf..f69dddab2 100644 --- a/src/main/java/appeng/core/sync/packets/PacketValueConfig.java +++ b/src/main/java/appeng/core/sync/packets/PacketValueConfig.java @@ -24,6 +24,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; +import appeng.container.implementations.*; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -40,17 +41,6 @@ import appeng.api.util.IConfigManager; import appeng.api.util.IConfigurableObject; import appeng.client.gui.implementations.GuiCraftingCPU; import appeng.container.AEBaseContainer; -import appeng.container.implementations.ContainerCellWorkbench; -import appeng.container.implementations.ContainerCraftConfirm; -import appeng.container.implementations.ContainerCraftingCPU; -import appeng.container.implementations.ContainerCraftingStatus; -import appeng.container.implementations.ContainerLevelEmitter; -import appeng.container.implementations.ContainerNetworkTool; -import appeng.container.implementations.ContainerPatternTerm; -import appeng.container.implementations.ContainerPriority; -import appeng.container.implementations.ContainerQuartzKnife; -import appeng.container.implementations.ContainerSecurityStation; -import appeng.container.implementations.ContainerStorageBus; import appeng.core.sync.AppEngPacket; import appeng.core.sync.network.INetworkInfo; import appeng.fluids.container.ContainerFluidLevelEmitter; @@ -166,58 +156,109 @@ public class PacketValueConfig extends AppEngPacket final ContainerFluidLevelEmitter lvc = (ContainerFluidLevelEmitter) c; lvc.setLevel( Long.parseLong( this.Value ), player ); } - else if( this.Name.startsWith( "PatternTerminal." ) && c instanceof ContainerPatternTerm ) + else if( this.Name.startsWith( "PatternTerminal." ) ) { - final ContainerPatternTerm cpt = (ContainerPatternTerm) c; - if( this.Name.equals( "PatternTerminal.CraftMode" ) ) + if( c instanceof ContainerPatternTerm ) { - cpt.getPatternTerminal().setCraftingRecipe( this.Value.equals( "1" ) ); - } - else if( this.Name.equals( "PatternTerminal.Encode" ) ) - { - if (this.Value.equals( "2" )) { - cpt.encodeAndMoveToInventory(); - } - else + final ContainerPatternTerm cpt = (ContainerPatternTerm) c; + if( this.Name.equals( "PatternTerminal.CraftMode" ) ) { - cpt.encode(); + cpt.getPatternTerminal().setCraftingRecipe( this.Value.equals( "1" ) ); + } + else if( this.Name.equals( "PatternTerminal.Encode" ) ) + { + if( this.Value.equals( "2" ) ) + { + cpt.encodeAndMoveToInventory(); + } + else + { + cpt.encode(); + } + } + else if( this.Name.equals( "PatternTerminal.Clear" ) ) + { + cpt.clear(); + } + else if( this.Name.equals( "PatternTerminal.MultiplyByTwo" ) ) + { + cpt.multiply( 2 ); + } + else if( this.Name.equals( "PatternTerminal.MultiplyByThree" ) ) + { + cpt.multiply( 3 ); + } + else if( this.Name.equals( "PatternTerminal.DivideByTwo" ) ) + { + cpt.divide( 2 ); + } + else if( this.Name.equals( "PatternTerminal.DivideByThree" ) ) + { + cpt.divide( 3 ); + } + else if( this.Name.equals( "PatternTerminal.IncreaseByOne" ) ) + { + cpt.increase( 1 ); + } + else if( this.Name.equals( "PatternTerminal.DecreaseByOne" ) ) + { + cpt.decrease( 1 ); + } + else if( this.Name.equals( "PatternTerminal.MaximizeCount" ) ) + { + cpt.maximizeCount(); + } + else if( this.Name.equals( "PatternTerminal.Substitute" ) ) + { + cpt.getPatternTerminal().setSubstitution( this.Value.equals( "1" ) ); } } - else if( this.Name.equals( "PatternTerminal.Clear" ) ) + else if( c instanceof ContainerExpandedProcessingPatternTerm ) { - cpt.clear(); - } - else if( this.Name.equals( "PatternTerminal.MultiplyByTwo" ) ) - { - cpt.multiply(2); - } - else if( this.Name.equals( "PatternTerminal.MultiplyByThree" ) ) - { - cpt.multiply(3); - } - else if( this.Name.equals( "PatternTerminal.DivideByTwo" ) ) - { - cpt.divide(2); - } - else if( this.Name.equals( "PatternTerminal.DivideByThree" ) ) - { - cpt.divide(3); - } - else if( this.Name.equals( "PatternTerminal.IncreaseByOne" ) ) - { - cpt.increase(1); - } - else if( this.Name.equals( "PatternTerminal.DecreaseByOne" ) ) - { - cpt.decrease(1); - } - else if( this.Name.equals( "PatternTerminal.MaximizeCount" ) ) - { - cpt.maximizeCount(); - } - else if( this.Name.equals( "PatternTerminal.Substitute" ) ) - { - cpt.getPatternTerminal().setSubstitution( this.Value.equals( "1" ) ); + final ContainerExpandedProcessingPatternTerm cept = (ContainerExpandedProcessingPatternTerm) c; + if( this.Name.equals( "PatternTerminal.Encode" ) ) + { + if( this.Value.equals( "2" ) ) + { + cept.encodeAndMoveToInventory(); + } + else + { + cept.encode(); + } + } + else if( this.Name.equals( "PatternTerminal.Clear" ) ) + { + cept.clear(); + } + else if( this.Name.equals( "PatternTerminal.MultiplyByTwo" ) ) + { + cept.multiply( 2 ); + } + else if( this.Name.equals( "PatternTerminal.MultiplyByThree" ) ) + { + cept.multiply( 3 ); + } + else if( this.Name.equals( "PatternTerminal.DivideByTwo" ) ) + { + cept.divide( 2 ); + } + else if( this.Name.equals( "PatternTerminal.DivideByThree" ) ) + { + cept.divide( 3 ); + } + else if( this.Name.equals( "PatternTerminal.IncreaseByOne" ) ) + { + cept.increase( 1 ); + } + else if( this.Name.equals( "PatternTerminal.DecreaseByOne" ) ) + { + cept.decrease( 1 ); + } + else if( this.Name.equals( "PatternTerminal.MaximizeCount" ) ) + { + cept.maximizeCount(); + } } } else if( this.Name.startsWith( "StorageBus." ) ) diff --git a/src/main/java/appeng/helpers/PatternHelper.java b/src/main/java/appeng/helpers/PatternHelper.java index d6930d689..ea99a9bbf 100644 --- a/src/main/java/appeng/helpers/PatternHelper.java +++ b/src/main/java/appeng/helpers/PatternHelper.java @@ -20,7 +20,6 @@ package appeng.helpers; import java.util.*; -import java.util.stream.Collectors; import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.Item; @@ -38,9 +37,6 @@ import appeng.api.networking.crafting.ICraftingPatternDetails; import appeng.api.storage.channels.IItemStorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.container.ContainerNull; -import appeng.core.AEConfig; -import appeng.core.AELog; -import appeng.core.features.AEFeature; import appeng.util.Platform; import appeng.util.item.AEItemStack; import net.minecraftforge.common.crafting.IShapedRecipe; @@ -50,13 +46,14 @@ public class PatternHelper implements ICraftingPatternDetails, Comparable(ALL_INPUT_LIMIT); + this.inputs = in.toArray( new IAEItemStack[isCrafting ? CRAFTING_INPUT_LIMIT : PROCESSING_INPUT_LIMIT] ); + this.outputs = out.toArray( new IAEItemStack[outputLength] ); + this.substituteInputs = new HashMap<>( CRAFTING_INPUT_LIMIT ); final Map tmpOutputs = new HashMap<>(); diff --git a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java index 9a65009d4..cf1c17164 100644 --- a/src/main/java/appeng/integration/modules/jei/JEIPlugin.java +++ b/src/main/java/appeng/integration/modules/jei/JEIPlugin.java @@ -26,6 +26,7 @@ import java.util.List; import java.util.Optional; import appeng.client.gui.AEGuiHandler; +import appeng.container.implementations.ContainerExpandedProcessingPatternTerm; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; @@ -90,16 +91,13 @@ public class JEIPlugin implements IModPlugin this.registerDescriptions( definitions, registry ); // Allow recipe transfer from JEI to crafting and pattern terminal - registry.getRecipeTransferRegistry() - .addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerCraftingTerm.class ), - VanillaRecipeCategoryUid.CRAFTING ); - registry.getRecipeTransferRegistry() - .addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ), - Constants.UNIVERSAL_RECIPE_TRANSFER_UID ); + registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerCraftingTerm.class ), VanillaRecipeCategoryUid.CRAFTING ); + registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerPatternTerm.class ), Constants.UNIVERSAL_RECIPE_TRANSFER_UID ); + registry.getRecipeTransferRegistry().addRecipeTransferHandler( new RecipeTransferHandler<>( ContainerExpandedProcessingPatternTerm.class ), Constants.UNIVERSAL_RECIPE_TRANSFER_UID ); aeGuiHandler = new AEGuiHandler(); - registry.addAdvancedGuiHandlers(aeGuiHandler); - registry.addGhostIngredientHandler( aeGuiHandler.getGuiContainerClass(), aeGuiHandler); + registry.addAdvancedGuiHandlers( aeGuiHandler ); + registry.addGhostIngredientHandler( aeGuiHandler.getGuiContainerClass(), aeGuiHandler ); } private void registerDescriptions( IDefinitions definitions, IModRegistry registry ) diff --git a/src/main/java/appeng/items/parts/PartType.java b/src/main/java/appeng/items/parts/PartType.java index 75838da0a..881911434 100644 --- a/src/main/java/appeng/items/parts/PartType.java +++ b/src/main/java/appeng/items/parts/PartType.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Set; import java.util.stream.Collectors; +import appeng.parts.reporting.*; import com.google.common.collect.ImmutableList; import net.minecraft.client.renderer.block.model.ModelResourceLocation; @@ -75,15 +76,6 @@ import appeng.parts.p2p.PartP2PItems; import appeng.parts.p2p.PartP2PLight; import appeng.parts.p2p.PartP2PRedstone; import appeng.parts.p2p.PartP2PTunnelME; -import appeng.parts.reporting.PartConversionMonitor; -import appeng.parts.reporting.PartCraftingTerminal; -import appeng.parts.reporting.PartDarkPanel; -import appeng.parts.reporting.PartInterfaceTerminal; -import appeng.parts.reporting.PartPanel; -import appeng.parts.reporting.PartPatternTerminal; -import appeng.parts.reporting.PartSemiDarkPanel; -import appeng.parts.reporting.PartStorageMonitor; -import appeng.parts.reporting.PartTerminal; import appeng.util.Platform; @@ -211,94 +203,83 @@ public enum PartType FLUID_EXPORT_BUS( 261, "fluid_export_bus", EnumSet.of( AEFeature.FLUID_EXPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidExportBus.class ), LEVEL_EMITTER( 280, "level_emitter", EnumSet.of( AEFeature.LEVEL_EMITTER ), EnumSet.noneOf( IntegrationType.class ), PartLevelEmitter.class ), - FLUID_LEVEL_EMITTER( 281, "fluid_level_emitter", EnumSet.of( AEFeature.FLUID_LEVEL_EMITTER ), EnumSet - .noneOf( IntegrationType.class ), PartFluidLevelEmitter.class ), + FLUID_LEVEL_EMITTER( 281, "fluid_level_emitter", EnumSet.of( AEFeature.FLUID_LEVEL_EMITTER ), EnumSet.noneOf( IntegrationType.class ), PartFluidLevelEmitter.class ), - ANNIHILATION_PLANE( 300, "annihilation_plane", EnumSet.of( AEFeature.ANNIHILATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartAnnihilationPlane.class ), + ANNIHILATION_PLANE( 300, "annihilation_plane", EnumSet.of( AEFeature.ANNIHILATION_PLANE ), EnumSet.noneOf( IntegrationType.class ), PartAnnihilationPlane.class ), - IDENTITY_ANNIHILATION_PLANE( 301, "identity_annihilation_plane", EnumSet.of( AEFeature.ANNIHILATION_PLANE, AEFeature.IDENTITY_ANNIHILATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartIdentityAnnihilationPlane.class ), + IDENTITY_ANNIHILATION_PLANE( 301, "identity_annihilation_plane", EnumSet.of( AEFeature.ANNIHILATION_PLANE, AEFeature.IDENTITY_ANNIHILATION_PLANE ), EnumSet.noneOf( IntegrationType.class ), PartIdentityAnnihilationPlane.class ), - FLUID_ANNIHILATION_PLANE( 302, "fluid_annihilation_plane", EnumSet.of( AEFeature.FLUID_ANNIHILATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartFluidAnnihilationPlane.class ), + FLUID_ANNIHILATION_PLANE( 302, "fluid_annihilation_plane", EnumSet.of( AEFeature.FLUID_ANNIHILATION_PLANE ), EnumSet.noneOf( IntegrationType.class ), PartFluidAnnihilationPlane.class ), FORMATION_PLANE( 320, "formation_plane", EnumSet.of( AEFeature.FORMATION_PLANE ), EnumSet.noneOf( IntegrationType.class ), PartFormationPlane.class ), - FLUID_FORMATION_PLANE( 321, "fluid_formation_plane", EnumSet.of( AEFeature.FLUID_FORMATION_PLANE ), EnumSet - .noneOf( IntegrationType.class ), PartFluidFormationPlane.class ), + FLUID_FORMATION_PLANE( 321, "fluid_formation_plane", EnumSet.of( AEFeature.FLUID_FORMATION_PLANE ), EnumSet.noneOf( IntegrationType.class ), PartFluidFormationPlane.class ), PATTERN_TERMINAL( 340, "pattern_terminal", EnumSet.of( AEFeature.PATTERNS ), EnumSet.noneOf( IntegrationType.class ), PartPatternTerminal.class ), - CRAFTING_TERMINAL( 360, "crafting_terminal", EnumSet.of( AEFeature.CRAFTING_TERMINAL ), EnumSet - .noneOf( IntegrationType.class ), PartCraftingTerminal.class ), + EXPANDED_PROCESSING_PATTERN_TERMINAL( 341, "expanded_processing_pattern_terminal", EnumSet.of( AEFeature.PATTERNS ), EnumSet.noneOf( IntegrationType.class ), PartExpandedProcessingPatternTerminal.class ), + + CRAFTING_TERMINAL( 360, "crafting_terminal", EnumSet.of( AEFeature.CRAFTING_TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartCraftingTerminal.class ), TERMINAL( 380, "terminal", EnumSet.of( AEFeature.TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartTerminal.class ), STORAGE_MONITOR( 400, "storage_monitor", EnumSet.of( AEFeature.STORAGE_MONITOR ), EnumSet.noneOf( IntegrationType.class ), PartStorageMonitor.class ), - CONVERSION_MONITOR( 420, "conversion_monitor", EnumSet.of( AEFeature.PART_CONVERSION_MONITOR ), EnumSet - .noneOf( IntegrationType.class ), PartConversionMonitor.class ), + CONVERSION_MONITOR( 420, "conversion_monitor", EnumSet.of( AEFeature.PART_CONVERSION_MONITOR ), EnumSet.noneOf( IntegrationType.class ), PartConversionMonitor.class ), INTERFACE( 440, "interface", EnumSet.of( AEFeature.INTERFACE ), EnumSet.noneOf( IntegrationType.class ), PartInterface.class ), FLUID_INTERFACE( 441, "fluid_interface", EnumSet.of( AEFeature.FLUID_INTERFACE ), EnumSet.noneOf( IntegrationType.class ), PartFluidInterface.class ), - P2P_TUNNEL_ME( 460, "p2p_tunnel_me", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ME ), EnumSet - .noneOf( IntegrationType.class ), PartP2PTunnelME.class, GuiText.METunnel ) - { - @Override - String getUnlocalizedName() - { - return "p2p_tunnel"; - } - }, + P2P_TUNNEL_ME( 460, "p2p_tunnel_me", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ME ), EnumSet.noneOf( IntegrationType.class ), PartP2PTunnelME.class, GuiText.METunnel ) + { + @Override + String getUnlocalizedName() + { + return "p2p_tunnel"; + } + }, - P2P_TUNNEL_REDSTONE( 461, "p2p_tunnel_redstone", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_REDSTONE ), EnumSet - .noneOf( IntegrationType.class ), PartP2PRedstone.class, GuiText.RedstoneTunnel ) - { - @Override - String getUnlocalizedName() - { - return "p2p_tunnel"; - } - }, + P2P_TUNNEL_REDSTONE( 461, "p2p_tunnel_redstone", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_REDSTONE ), EnumSet.noneOf( IntegrationType.class ), PartP2PRedstone.class, GuiText.RedstoneTunnel ) + { + @Override + String getUnlocalizedName() + { + return "p2p_tunnel"; + } + }, - P2P_TUNNEL_ITEMS( 462, "p2p_tunnel_items", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ITEMS ), EnumSet - .noneOf( IntegrationType.class ), PartP2PItems.class, GuiText.ItemTunnel ) - { - @Override - String getUnlocalizedName() - { - return "p2p_tunnel"; - } - }, + P2P_TUNNEL_ITEMS( 462, "p2p_tunnel_items", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_ITEMS ), EnumSet.noneOf( IntegrationType.class ), PartP2PItems.class, GuiText.ItemTunnel ) + { + @Override + String getUnlocalizedName() + { + return "p2p_tunnel"; + } + }, - P2P_TUNNEL_FLUIDS( 463, "p2p_tunnel_fluids", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS ), EnumSet - .noneOf( IntegrationType.class ), PartP2PFluids.class, GuiText.FluidTunnel ) - { - @Override - String getUnlocalizedName() - { - return "p2p_tunnel"; - } - }, + P2P_TUNNEL_FLUIDS( 463, "p2p_tunnel_fluids", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_FLUIDS ), EnumSet.noneOf( IntegrationType.class ), PartP2PFluids.class, GuiText.FluidTunnel ) + { + @Override + String getUnlocalizedName() + { + return "p2p_tunnel"; + } + }, - P2P_TUNNEL_IC2( 465, "p2p_tunnel_ic2", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_EU ), EnumSet - .of( IntegrationType.IC2 ), PartP2PIC2Power.class, GuiText.EUTunnel ) - { - @Override - String getUnlocalizedName() - { - return "p2p_tunnel"; - } - }, + P2P_TUNNEL_IC2( 465, "p2p_tunnel_ic2", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_EU ), EnumSet.of( IntegrationType.IC2 ), PartP2PIC2Power.class, GuiText.EUTunnel ) + { + @Override + String getUnlocalizedName() + { + return "p2p_tunnel"; + } + }, - P2P_TUNNEL_LIGHT( 467, "p2p_tunnel_light", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT ), EnumSet - .noneOf( IntegrationType.class ), PartP2PLight.class, GuiText.LightTunnel ) - { - @Override - String getUnlocalizedName() - { + P2P_TUNNEL_LIGHT( 467, "p2p_tunnel_light", EnumSet.of( AEFeature.P2P_TUNNEL, AEFeature.P2P_TUNNEL_LIGHT ), EnumSet.noneOf( IntegrationType.class ), PartP2PLight.class, GuiText.LightTunnel ) + { + @Override + String getUnlocalizedName() + { return "p2p_tunnel"; } }, diff --git a/src/main/java/appeng/me/GridNode.java b/src/main/java/appeng/me/GridNode.java index 6bd41ff28..22bf72e02 100644 --- a/src/main/java/appeng/me/GridNode.java +++ b/src/main/java/appeng/me/GridNode.java @@ -59,6 +59,7 @@ import appeng.me.cache.CraftingGridCache; import appeng.me.pathfinding.IPathItem; import appeng.util.IWorldCallable; import appeng.util.ReadOnlyCollection; +import net.minecraftforge.common.util.Constants; public class GridNode implements IGridNode, IPathItem @@ -333,7 +334,11 @@ public class GridNode implements IGridNode, IPathItem @Override public void loadFromNBT( final String name, final NBTTagCompound nodeData ) { - if( this.myGrid == null ) + if( this.myGrid != null ) + { + throw new IllegalStateException( "Loading data after part of a grid, this is invalid." ); + } + if( nodeData.hasKey( name, 10 ) ) { final NBTTagCompound node = nodeData.getCompoundTag( name ); this.playerID = node.getInteger( "p" ); @@ -345,7 +350,9 @@ public class GridNode implements IGridNode, IPathItem } else { - throw new IllegalStateException( "Loading data after part of a grid, this is invalid." ); + this.playerID = -1; // Unknown owner + setLastSecurityKey( -1 ); + setGridStorage( null ); } } diff --git a/src/main/java/appeng/parts/reporting/PartExpandedProcessingPatternTerminal.java b/src/main/java/appeng/parts/reporting/PartExpandedProcessingPatternTerminal.java new file mode 100644 index 000000000..79791a6ea --- /dev/null +++ b/src/main/java/appeng/parts/reporting/PartExpandedProcessingPatternTerminal.java @@ -0,0 +1,138 @@ +package appeng.parts.reporting; + +import appeng.api.implementations.ICraftingPatternItem; +import appeng.api.networking.crafting.ICraftingPatternDetails; +import appeng.api.parts.IPartModel; +import appeng.api.storage.data.IAEItemStack; +import appeng.core.AppEng; +import appeng.core.sync.GuiBridge; +import appeng.helpers.Reflected; +import appeng.items.parts.PartModels; +import appeng.parts.PartModel; +import appeng.tile.inventory.AppEngInternalInventory; +import appeng.util.inv.InvOperation; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.items.IItemHandler; + +import static appeng.helpers.PatternHelper.PROCESSING_INPUT_LIMIT; +import static appeng.helpers.PatternHelper.PROCESSING_OUTPUT_LIMIT; + + +public class PartExpandedProcessingPatternTerminal extends AbstractPartTerminal +{ + @PartModels + public static final ResourceLocation MODEL_OFF = new ResourceLocation( AppEng.MOD_ID, "part/expanded_processing_pattern_terminal_off" ); + @PartModels + public static final ResourceLocation MODEL_ON = new ResourceLocation( AppEng.MOD_ID, "part/expanded_processing_pattern_terminal_on" ); + + public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_OFF, MODEL_STATUS_OFF ); + public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_ON ); + public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_ON, MODEL_STATUS_HAS_CHANNEL ); + + private final AppEngInternalInventory crafting = new AppEngInternalInventory( this, PROCESSING_INPUT_LIMIT ); + + private final AppEngInternalInventory output = new AppEngInternalInventory( this, PROCESSING_OUTPUT_LIMIT ); + private final AppEngInternalInventory pattern = new AppEngInternalInventory( this, 2 ); + + @Reflected + public PartExpandedProcessingPatternTerminal( final ItemStack is ) + { + super( is ); + } + + @Override + public void readFromNBT( NBTTagCompound data ) + { + super.readFromNBT( data ); + this.crafting.readFromNBT( data, "processingGrid" ); + this.pattern.readFromNBT( data, "pattern" ); + this.output.readFromNBT( data, "outputList" ); + } + + @Override + public void writeToNBT( NBTTagCompound data ) + { + super.writeToNBT( data ); + this.crafting.writeToNBT( data, "processingGrid" ); + this.pattern.writeToNBT( data, "pattern" ); + this.output.writeToNBT( data, "outputList" ); + } + + @Override + public GuiBridge getGui( final EntityPlayer p ) + { + int x = (int) p.posX; + int y = (int) p.posY; + int z = (int) p.posZ; + if( this.getHost().getTile() != null ) + { + x = this.getTile().getPos().getX(); + y = this.getTile().getPos().getY(); + z = this.getTile().getPos().getZ(); + } + + if( GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL.hasPermissions( this.getHost().getTile(), x, y, z, this.getSide(), p ) ) + { + return GuiBridge.GUI_EXPANDED_PROCESSING_PATTERN_TERMINAL; + } + return GuiBridge.GUI_ME; + } + + @Override + public void onChangeInventory( final IItemHandler 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.isEmpty() && is.getItem() instanceof ICraftingPatternItem ) + { + final ICraftingPatternItem pattern = (ICraftingPatternItem) is.getItem(); + final ICraftingPatternDetails details = pattern.getPatternForItem( is, this.getHost().getTile().getWorld() ); + if( details != null ) + { + for( int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++ ) + { + final IAEItemStack item = details.getInputs()[x]; + this.crafting.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() ); + } + + for( int x = 0; x < this.output.getSlots() && x < details.getOutputs().length; x++ ) + { + final IAEItemStack item = details.getOutputs()[x]; + this.output.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.createItemStack() ); + } + } + } + } + + this.getHost().markForSave(); + } + + @Override + public IItemHandler getInventoryByName( final String name ) + { + if( name.equals( "crafting" ) ) + { + return this.crafting; + } + if( name.equals( "output" ) ) + { + return this.output; + } + if( name.equals( "pattern" ) ) + { + return this.pattern; + } + return super.getInventoryByName( name ); + } + + @Override + public IPartModel getStaticModels() + { + return this.selectModel( MODELS_OFF, MODELS_ON, MODELS_HAS_CHANNEL ); + } +} + diff --git a/src/main/resources/assets/appliedenergistics2/lang/en_us.lang b/src/main/resources/assets/appliedenergistics2/lang/en_us.lang index 6332b1eaa..3355a4493 100644 --- a/src/main/resources/assets/appliedenergistics2/lang/en_us.lang +++ b/src/main/resources/assets/appliedenergistics2/lang/en_us.lang @@ -535,6 +535,7 @@ item.appliedenergistics2.multi_part.level_emitter.name=ME Level Emitter item.appliedenergistics2.multi_part.fluid_level_emitter.name=ME Fluid Level Emitter item.appliedenergistics2.multi_part.p2p_tunnel.name=P2P Tunnel item.appliedenergistics2.multi_part.pattern_terminal.name=ME Pattern Terminal +item.appliedenergistics2.multi_part.expanded_processing_pattern_terminal.name=ME Extended Processing Pattern Terminal item.appliedenergistics2.multi_part.quartz_fiber.name=Quartz Fiber item.appliedenergistics2.multi_part.storage_bus.name=ME Storage Bus item.appliedenergistics2.multi_part.fluid_storage_bus.name=ME Fluid Storage Bus diff --git a/src/main/resources/assets/appliedenergistics2/models/item/part/expanded_processing_pattern_terminal.json b/src/main/resources/assets/appliedenergistics2/models/item/part/expanded_processing_pattern_terminal.json new file mode 100644 index 000000000..4c35dc50c --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/item/part/expanded_processing_pattern_terminal.json @@ -0,0 +1,9 @@ +{ + "parent": "appliedenergistics2:item/part/display", + "textures": { + "front": "appliedenergistics2:items/part/expanded_processing_pattern_terminal", + "front_bright": "appliedenergistics2:parts/expanded_processing_pattern_terminal_bright", + "front_medium": "appliedenergistics2:parts/expanded_processing_pattern_terminal_medium", + "front_dark": "appliedenergistics2:parts/pattern_terminal_dark" + } +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/expanded_processing_pattern_terminal_off.json b/src/main/resources/assets/appliedenergistics2/models/part/expanded_processing_pattern_terminal_off.json new file mode 100644 index 000000000..dc116b127 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/part/expanded_processing_pattern_terminal_off.json @@ -0,0 +1,8 @@ +{ + "parent": "appliedenergistics2:part/display_off", + "textures": { + "lightsBright": "appliedenergistics2:parts/expanded_processing_pattern_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/expanded_processing_pattern_terminal_medium", + "lightsDark": "appliedenergistics2:parts/pattern_terminal_dark" + } +} diff --git a/src/main/resources/assets/appliedenergistics2/models/part/expanded_processing_pattern_terminal_on.json b/src/main/resources/assets/appliedenergistics2/models/part/expanded_processing_pattern_terminal_on.json new file mode 100644 index 000000000..920788919 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/models/part/expanded_processing_pattern_terminal_on.json @@ -0,0 +1,76 @@ +{ + "ae2_uvl_marker": true, + "textures": { + "lightsBright": "appliedenergistics2:parts/expanded_processing_pattern_terminal_bright", + "lightsMedium": "appliedenergistics2:parts/expanded_processing_pattern_terminal_medium", + "lightsDark": "appliedenergistics2:parts/pattern_terminal_dark" + }, + "elements": [ + { + "from": [ + 2, + 2, + 0 + ], + "to": [ + 14, + 14, + 2 + ], + "faces": { + "north": { + "texture": "#lightsBright", + "tintindex": 3, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [ + 2, + 2, + 0 + ], + "to": [ + 14, + 14, + 2 + ], + "faces": { + "north": { + "texture": "#lightsMedium", + "tintindex": 2, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + }, + { + "from": [ + 2, + 2, + 0 + ], + "to": [ + 14, + 14, + 2 + ], + "faces": { + "north": { + "texture": "#lightsDark", + "tintindex": 1, + "uvlightmap": { + "sky": 0.007, + "block": 0.007 + } + } + } + } + ] +} diff --git a/src/main/resources/assets/appliedenergistics2/recipes/network/parts/terminal_expanded_processing.json b/src/main/resources/assets/appliedenergistics2/recipes/network/parts/terminal_expanded_processing.json new file mode 100644 index 000000000..8362406a1 --- /dev/null +++ b/src/main/resources/assets/appliedenergistics2/recipes/network/parts/terminal_expanded_processing.json @@ -0,0 +1,41 @@ +{ + "conditions": [ + { + "type": "forge:and", + "values": [ + { + "type": "appliedenergistics2:part_exists", + "part": "part.pattern_terminal" + }, + { + "type": "appliedenergistics2:material_exists", + "material": "material.calculation_processor" + } + ] + } + ], + "result": { + "type": "appliedenergistics2:part", + "part": "part.expanded_processing_pattern_terminal" + }, + "type": "appliedenergistics2:part_shaped", + "pattern": [ + "c c", + "tft", + "c c" + ], + "key": { + "f": { + "type": "appliedenergistics2:part", + "part": "cable_glass.fluix" + }, + "t": { + "type": "appliedenergistics2:part", + "part": "part.pattern_terminal" + }, + "c": { + "type": "appliedenergistics2:part", + "part": "material.calculation_processor" + } + } +} diff --git a/src/main/resources/assets/appliedenergistics2/textures/guis/pattern_processing_expanded.png b/src/main/resources/assets/appliedenergistics2/textures/guis/pattern_processing_expanded.png new file mode 100644 index 000000000..fe46cb2e8 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/guis/pattern_processing_expanded.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/items/part/expanded_processing_pattern_terminal.png b/src/main/resources/assets/appliedenergistics2/textures/items/part/expanded_processing_pattern_terminal.png new file mode 100644 index 000000000..335a451d4 Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/items/part/expanded_processing_pattern_terminal.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/parts/expanded_processing_pattern_terminal_bright.png b/src/main/resources/assets/appliedenergistics2/textures/parts/expanded_processing_pattern_terminal_bright.png new file mode 100644 index 000000000..6615e5f5c Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/parts/expanded_processing_pattern_terminal_bright.png differ diff --git a/src/main/resources/assets/appliedenergistics2/textures/parts/expanded_processing_pattern_terminal_medium.png b/src/main/resources/assets/appliedenergistics2/textures/parts/expanded_processing_pattern_terminal_medium.png new file mode 100644 index 000000000..6f78a744b Binary files /dev/null and b/src/main/resources/assets/appliedenergistics2/textures/parts/expanded_processing_pattern_terminal_medium.png differ