diff --git a/src/main/java/resonantinduction/archaic/Archaic.java b/src/main/java/resonantinduction/archaic/Archaic.java index be9f47d7d..7da4110f1 100644 --- a/src/main/java/resonantinduction/archaic/Archaic.java +++ b/src/main/java/resonantinduction/archaic/Archaic.java @@ -3,6 +3,8 @@ package resonantinduction.archaic; import net.minecraft.block.Block; import resonantinduction.archaic.crate.BlockCrate; import resonantinduction.archaic.crate.TileCrate; +import resonantinduction.archaic.engineering.BlockEngineeringTable; +import resonantinduction.archaic.engineering.TileEngineeringTable; import resonantinduction.core.Reference; import resonantinduction.core.ResonantInduction; import resonantinduction.core.Settings; @@ -43,12 +45,14 @@ public class Archaic public static final ContentRegistry contentRegistry = new ContentRegistry(Settings.CONFIGURATION, ID); + public static Block blockEngineeringTable; public static Block blockCrate; @EventHandler public void preInit(FMLPreInitializationEvent evt) { NetworkRegistry.instance().registerGuiHandler(this, proxy); + blockEngineeringTable = contentRegistry.createTile(BlockEngineeringTable.class, TileEngineeringTable.class); blockCrate = contentRegistry.createTile(BlockCrate.class, TileCrate.class); proxy.preInit(); } diff --git a/src/main/java/resonantinduction/archaic/crafting/BlockEngineeringTable.java b/src/main/java/resonantinduction/archaic/crafting/BlockEngineeringTable.java deleted file mode 100644 index 3c031c8b0..000000000 --- a/src/main/java/resonantinduction/archaic/crafting/BlockEngineeringTable.java +++ /dev/null @@ -1,115 +0,0 @@ -package resonantinduction.archaic.crafting; - -import net.minecraft.block.Block; -import net.minecraft.client.renderer.texture.IconRegister; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.util.Icon; -import net.minecraft.world.World; -import resonantinduction.core.prefab.block.BlockRI; -import cpw.mods.fml.relauncher.Side; -import cpw.mods.fml.relauncher.SideOnly; - -/** - * Advanced tiering of a crafting table adding advanced features such as visual crafting, and auto - * crafting. Original idea by Infinite - * - * @author DarkGuardsman - */ -public class BlockEngineeringTable extends BlockRI -{ - @SideOnly(Side.CLIENT) - private Icon workbenchIconTop; - @SideOnly(Side.CLIENT) - private Icon workbenchIconFront; - - public BlockEngineeringTable() - { - super("craftingDesk"); - } - - @Override - @SideOnly(Side.CLIENT) - public Icon getIcon(int par1, int par2) - { - return par1 == 1 ? this.workbenchIconTop : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.workbenchIconFront)); - } - - @Override - @SideOnly(Side.CLIENT) - public void registerIcons(IconRegister par1IconRegister) - { - this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side"); - this.workbenchIconTop = par1IconRegister.registerIcon(this.getTextureName() + "_top"); - this.workbenchIconFront = par1IconRegister.registerIcon(this.getTextureName() + "_front"); - } - - @Override - public TileEntity createNewTileEntity(World world) - { - return new TileEngineeringTable(); - } - - @Override - public TileEntity createTileEntity(World world, int metadata) - { - if (metadata >= 0 && metadata < CraftingTables.values().length) - { - CraftingTables table = CraftingTables.values()[metadata]; - if (table.enabled && table.tileClass != null) - { - try - { - return table.tileClass.newInstance(); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - } - return super.createTileEntity(world, metadata); - } - - public static enum CraftingTables - { - /** Upgraded wooden crafting table, stores items, and contains a small inventory */ - ADVANCED(), - /** Stone version of the advanced, renders end result of crafting on surface */ - STONE(), - /** Iron version of stone adding ability to repair armor */ - IRON(), - /** Upgraded version of the iron allowing repair of tools, as well upgrades of tools */ - STEEL(), - /** First work bench that can be combined with robotics to auto craft items */ - AUTOMATED(), - /** Crafting table that allows large long term projects to be made one item at a time */ - PROJECT(), - /** Crafting table that allows industrial machines to be crafted */ - INDUSTRIAL(), - /** - * Crafting table that allows advanced electronics to be crafted, also allows electronic - * devices to be designed - */ - ELECTRONICS(), - /** Upgraded auto table that can use blueprints, works faster, and do some cool tricks */ - INDUSTRIAL_AUTOMATED(), - /** Auto crafting version of the electronics table, allows autocrafting of custom devices */ - ELECTRONICS_AUTOMATED(), - /** Auto crafting table that allows long term projects to be made one item at a time */ - AUTOMATED_PROJECT(); - - public final boolean enabled; - public Class tileClass = null; - - private CraftingTables() - { - this(false); - } - - private CraftingTables(boolean enabled) - { - this.enabled = enabled; - } - } - -} diff --git a/src/main/java/resonantinduction/archaic/crafting/TileEngineeringTable.java b/src/main/java/resonantinduction/archaic/crafting/TileEngineeringTable.java deleted file mode 100644 index b62c148db..000000000 --- a/src/main/java/resonantinduction/archaic/crafting/TileEngineeringTable.java +++ /dev/null @@ -1,8 +0,0 @@ -package resonantinduction.archaic.crafting; - -import resonantinduction.core.prefab.tile.TileEntityInv; - -public class TileEngineeringTable extends TileEntityInv -{ - -} diff --git a/src/main/java/resonantinduction/archaic/engineering/BlockEngineeringTable.java b/src/main/java/resonantinduction/archaic/engineering/BlockEngineeringTable.java new file mode 100644 index 000000000..8d788ba86 --- /dev/null +++ b/src/main/java/resonantinduction/archaic/engineering/BlockEngineeringTable.java @@ -0,0 +1,58 @@ +package resonantinduction.archaic.engineering; + +import net.minecraft.block.Block; +import net.minecraft.client.renderer.texture.IconRegister; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Icon; +import net.minecraft.world.World; +import resonantinduction.core.prefab.block.BlockRI; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; + +/** + * Advanced tiering of a crafting table adding advanced features such as visual crafting, and auto + * crafting. Original idea by Infinite + * + * @author DarkGuardsman + */ +public class BlockEngineeringTable extends BlockRI +{ + @SideOnly(Side.CLIENT) + private Icon workbenchIconTop; + @SideOnly(Side.CLIENT) + private Icon workbenchIconFront; + + public BlockEngineeringTable() + { + super("engineeringTable"); + } + + @Override + public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int par6, float par7, float par8, float par9) + { + return false; + } + + @Override + @SideOnly(Side.CLIENT) + public Icon getIcon(int par1, int par2) + { + return par1 == 1 ? this.workbenchIconTop : (par1 == 0 ? Block.planks.getBlockTextureFromSide(par1) : (par1 != 2 && par1 != 4 ? this.blockIcon : this.workbenchIconFront)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons(IconRegister par1IconRegister) + { + this.blockIcon = par1IconRegister.registerIcon(this.getTextureName() + "_side"); + this.workbenchIconTop = par1IconRegister.registerIcon(this.getTextureName() + "_top"); + this.workbenchIconFront = par1IconRegister.registerIcon(this.getTextureName() + "_front"); + } + + @Override + public TileEntity createNewTileEntity(World world) + { + return new TileEngineeringTable(); + } +} diff --git a/src/main/java/resonantinduction/archaic/engineering/ContainerEngineering.java b/src/main/java/resonantinduction/archaic/engineering/ContainerEngineering.java index b86227029..aabcc28d0 100644 --- a/src/main/java/resonantinduction/archaic/engineering/ContainerEngineering.java +++ b/src/main/java/resonantinduction/archaic/engineering/ContainerEngineering.java @@ -5,6 +5,8 @@ import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.inventory.Container; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; +import resonantinduction.archaic.imprint.ItemBlockFilter; +import resonantinduction.archaic.imprint.TileImprinter; import calclavia.lib.prefab.slot.ISlotWatcher; import calclavia.lib.prefab.slot.SlotCraftingResult; import calclavia.lib.prefab.slot.SlotSpecific; @@ -13,9 +15,9 @@ import calclavia.lib.prefab.slot.SlotWatched; public class ContainerEngineering extends Container implements ISlotWatcher { public InventoryPlayer inventoryPlayer; - public TileImprinter tileEntity; + public TileEngineeringTable tileEntity; - public ContainerEngineering(InventoryPlayer inventoryPlayer, TileImprinter tileEntity) + public ContainerEngineering(InventoryPlayer inventoryPlayer, TileEngineeringTable tileEntity) { this.tileEntity = tileEntity; this.tileEntity.container = this; diff --git a/src/main/java/resonantinduction/archaic/engineering/TileEngineeringTable.java b/src/main/java/resonantinduction/archaic/engineering/TileEngineeringTable.java new file mode 100644 index 000000000..79e1b0780 --- /dev/null +++ b/src/main/java/resonantinduction/archaic/engineering/TileEngineeringTable.java @@ -0,0 +1,412 @@ +package resonantinduction.archaic.engineering; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.inventory.InventoryCrafting; +import net.minecraft.item.ItemStack; +import net.minecraft.item.crafting.CraftingManager; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraftforge.common.MinecraftForge; +import resonantinduction.api.IArmbot; +import resonantinduction.api.IArmbotUseable; +import resonantinduction.api.events.AutoCraftEvent; +import resonantinduction.archaic.imprint.ItemBlockFilter; +import resonantinduction.archaic.imprint.TileImprinter; +import resonantinduction.electrical.encoder.coding.args.ArgumentData; +import universalelectricity.api.vector.Vector3; +import calclavia.lib.prefab.slot.ISlotPickResult; +import calclavia.lib.prefab.tile.TileAdvanced; +import calclavia.lib.utility.AutoCraftingManager; +import calclavia.lib.utility.AutoCraftingManager.IAutoCrafter; +import calclavia.lib.utility.LanguageUtility; + +import com.builtbroken.common.Pair; + +public class TileEngineeringTable extends TileAdvanced implements ISidedInventory, IArmbotUseable, ISlotPickResult, IAutoCrafter +{ + public static final int CRAFTING_MATRIX_END = 9; + + private AutoCraftingManager craftManager; + + /** 9 slots for crafting, 1 slot for a output. */ + public ItemStack[] craftingMatrix = new ItemStack[9]; + public static final int[] craftingSlots = { 0, 1, 2, 3, 4, 5, 6, 7, 8 }; + + /** The output inventory containing slots. */ + public ItemStack[] output = new ItemStack[1]; + public final int craftingOutputSlot = 0; + public static int[] inventorySlots; + + /** The containing currently used by the imprinter. */ + public ContainerEngineering container; + + /** The ability for the imprinter to serach nearby inventories. */ + public boolean searchInventories = true; + + @Override + public boolean canUpdate() + { + return false; + } + + /** Gets the AutoCraftingManager that does all the crafting results */ + public AutoCraftingManager getCraftingManager() + { + if (craftManager == null) + { + craftManager = new AutoCraftingManager(this); + } + return craftManager; + } + + @Override + public int getSizeInventory() + { + return 10; + } + + /** + * Sets the given item stack to the specified slot in the inventory (can be crafting or armor + * sections). + */ + @Override + public void setInventorySlotContents(int slot, ItemStack itemStack) + { + if (slot < this.getSizeInventory()) + { + if (slot < CRAFTING_MATRIX_END) + { + this.craftingMatrix[slot] = itemStack; + } + else + { + this.output[slot - CRAFTING_MATRIX_END] = itemStack; + } + } + } + + @Override + public ItemStack decrStackSize(int i, int amount) + { + if (this.getStackInSlot(i) != null) + { + ItemStack stack; + + if (this.getStackInSlot(i).stackSize <= amount) + { + stack = this.getStackInSlot(i); + this.setInventorySlotContents(i, null); + return stack; + } + else + { + stack = this.getStackInSlot(i).splitStack(amount); + + if (this.getStackInSlot(i).stackSize == 0) + { + this.setInventorySlotContents(i, null); + } + + return stack; + } + } + else + { + return null; + } + } + + @Override + public ItemStack getStackInSlot(int slot) + { + if (slot < CRAFTING_MATRIX_END) + { + return this.craftingMatrix[slot]; + } + else + { + return this.output[slot - CRAFTING_MATRIX_END]; + } + } + + /** + * When some containers are closed they call this on each slot, then drop whatever it returns as + * an EntityItem - like when you close a workbench GUI. + */ + @Override + public ItemStack getStackInSlotOnClosing(int slot) + { + if (this.getStackInSlot(slot) != null) + { + ItemStack var2 = this.getStackInSlot(slot); + this.setInventorySlotContents(slot, null); + return var2; + } + else + { + return null; + } + } + + @Override + public String getInvName() + { + return LanguageUtility.getLocal("tile.imprinter.name"); + } + + @Override + public void openChest() + { + this.onInventoryChanged(); + } + + @Override + public void closeChest() + { + this.onInventoryChanged(); + } + + /** + * Construct an InventoryCrafting Matrix on the fly. + * + * @return + */ + public InventoryCrafting getCraftingMatrix() + { + if (this.container != null) + { + InventoryCrafting inventoryCrafting = new InventoryCrafting(this.container, 3, 3); + + for (int i = 0; i < this.craftingMatrix.length; i++) + { + inventoryCrafting.setInventorySlotContents(i, this.craftingMatrix[i]); + } + + return inventoryCrafting; + } + + return null; + } + + public void replaceCraftingMatrix(InventoryCrafting inventoryCrafting) + { + for (int i = 0; i < this.craftingMatrix.length; i++) + { + this.craftingMatrix[i] = inventoryCrafting.getStackInSlot(i); + } + } + + public boolean isMatrixEmpty() + { + for (int i = 0; i < 9; i++) + { + if (this.craftingMatrix[i] != null) + return false; + } + + return true; + } + + /** Updates all the output slots. Call this to update the Engineering Table. */ + @Override + public void onInventoryChanged() + { + if (!this.worldObj.isRemote) + { + this.output[craftingOutputSlot] = null; + + /** Try to craft from crafting grid. If not possible, then craft from imprint. */ + boolean didCraft = false; + + /** Simulate an Inventory Crafting Instance */ + InventoryCrafting inventoryCrafting = this.getCraftingMatrix(); + + if (inventoryCrafting != null) + { + ItemStack matrixOutput = CraftingManager.getInstance().findMatchingRecipe(inventoryCrafting, this.worldObj); + + if (matrixOutput != null && this.getCraftingManager().getIdealRecipe(matrixOutput) != null) + { + this.output[craftingOutputSlot] = matrixOutput; + didCraft = true; + } + } + + /* + if (this.output[imprintInputSlot] != null && !didCraft) + { + if (this.output[imprintInputSlot].getItem() instanceof ItemBlockFilter) + { + ArrayList filters = ItemBlockFilter.getFilters(this.output[0]); + + for (ItemStack outputStack : filters) + { + if (outputStack != null) + { + Pair idealRecipe = this.getCraftingManager().getIdealRecipe(outputStack); + + if (idealRecipe != null) + { + ItemStack recipeOutput = idealRecipe.left(); + if (recipeOutput != null & recipeOutput.stackSize > 0) + { + this.output[craftingOutputSlot] = recipeOutput; + didCraft = true; + break; + } + } + } + } + } + }*/ + } + } + + @Override + public void onPickUpFromSlot(EntityPlayer entityPlayer, int s, ItemStack itemStack) + { + if (itemStack != null) + { + + Pair idealRecipeItem = this.getCraftingManager().getIdealRecipe(itemStack); + + if (idealRecipeItem != null) + { + this.getCraftingManager().consumeItems(idealRecipeItem.right().clone()); + } + + } + } + + /** Tries to let the Armbot craft an item. */ + @Override + public boolean onUse(IArmbot armbot, List data) + { + this.onInventoryChanged(); + + /* + if (this.imprinterMatrix[craftingOutputSlot] != null) + { + AutoCraftEvent.PreCraft event = new AutoCraftEvent.PreCraft(this.worldObj, new Vector3(this), this, this.imprinterMatrix[craftingOutputSlot]); + MinecraftForge.EVENT_BUS.post(event); + + if (!event.isCanceled()) + { + armbot.grabObject(this.imprinterMatrix[craftingOutputSlot].copy()); + this.onPickUpFromSlot(null, 2, this.imprinterMatrix[craftingOutputSlot]); + this.imprinterMatrix[craftingOutputSlot] = null; + return true; + } + } +*/ + return false; + } + + // /////////////////////////////////////// + // // Save And Data processing ////// + // /////////////////////////////////////// + /** NBT Data */ + @Override + public void readFromNBT(NBTTagCompound nbt) + { + super.readFromNBT(nbt); + + NBTTagList var2 = nbt.getTagList("Items"); + this.craftingMatrix = new ItemStack[9]; + this.output = new ItemStack[1]; + + for (int i = 0; i < var2.tagCount(); ++i) + { + NBTTagCompound var4 = (NBTTagCompound) var2.tagAt(i); + byte var5 = var4.getByte("Slot"); + + if (var5 >= 0 && var5 < this.getSizeInventory()) + { + this.setInventorySlotContents(var5, ItemStack.loadItemStackFromNBT(var4)); + } + } + + this.searchInventories = nbt.getBoolean("searchInventories"); + } + + /** Writes a tile entity to NBT. */ + @Override + public void writeToNBT(NBTTagCompound nbt) + { + super.writeToNBT(nbt); + + NBTTagList var2 = new NBTTagList(); + + for (int i = 0; i < this.getSizeInventory(); ++i) + { + if (this.getStackInSlot(i) != null) + { + NBTTagCompound var4 = new NBTTagCompound(); + var4.setByte("Slot", (byte) i); + this.getStackInSlot(i).writeToNBT(var4); + var2.appendTag(var4); + } + } + + nbt.setTag("Items", var2); + + nbt.setBoolean("searchInventories", this.searchInventories); + } + + // /////////////////////////////////////// + // // Inventory Access side Methods ////// + // /////////////////////////////////////// + + @Override + public boolean isInvNameLocalized() + { + return false; + } + + @Override + public boolean isItemValidForSlot(int i, ItemStack itemstack) + { + return true; + } + + @Override + public int getInventoryStackLimit() + { + return 64; + } + + @Override + public boolean isUseableByPlayer(EntityPlayer entityplayer) + { + return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : entityplayer.getDistanceSq(this.xCoord + 0.5D, this.yCoord + 0.5D, this.zCoord + 0.5D) <= 64.0D; + + } + + @Override + public int[] getAccessibleSlotsFromSide(int side) + { + return this.getCraftingInv(); + } + + @Override + public boolean canInsertItem(int slot, ItemStack itemstack, int side) + { + return this.isItemValidForSlot(slot, itemstack); + } + + @Override + public boolean canExtractItem(int slot, ItemStack itemstack, int side) + { + return this.isItemValidForSlot(slot, itemstack); + } + + @Override + public int[] getCraftingInv() + { + return craftingSlots; + } +} diff --git a/src/main/java/resonantinduction/archaic/engineering/BlockFilter.java b/src/main/java/resonantinduction/archaic/imprint/BlockFilter.java similarity index 85% rename from src/main/java/resonantinduction/archaic/engineering/BlockFilter.java rename to src/main/java/resonantinduction/archaic/imprint/BlockFilter.java index c23351f59..c7927ab5f 100644 --- a/src/main/java/resonantinduction/archaic/engineering/BlockFilter.java +++ b/src/main/java/resonantinduction/archaic/imprint/BlockFilter.java @@ -1,4 +1,4 @@ -package resonantinduction.archaic.engineering; +package resonantinduction.archaic.imprint; import resonantinduction.core.prefab.block.BlockRotatableBase; diff --git a/src/main/java/resonantinduction/archaic/engineering/BlockImprinter.java b/src/main/java/resonantinduction/archaic/imprint/BlockImprinter.java similarity index 98% rename from src/main/java/resonantinduction/archaic/engineering/BlockImprinter.java rename to src/main/java/resonantinduction/archaic/imprint/BlockImprinter.java index 07ef5f608..8a74ccb23 100644 --- a/src/main/java/resonantinduction/archaic/engineering/BlockImprinter.java +++ b/src/main/java/resonantinduction/archaic/imprint/BlockImprinter.java @@ -1,4 +1,4 @@ -package resonantinduction.archaic.engineering; +package resonantinduction.archaic.imprint; import java.util.Random; diff --git a/src/main/java/resonantinduction/archaic/imprint/ContainerImprinter.java b/src/main/java/resonantinduction/archaic/imprint/ContainerImprinter.java new file mode 100644 index 000000000..329885929 --- /dev/null +++ b/src/main/java/resonantinduction/archaic/imprint/ContainerImprinter.java @@ -0,0 +1,145 @@ +package resonantinduction.archaic.imprint; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; +import calclavia.lib.prefab.slot.ISlotWatcher; +import calclavia.lib.prefab.slot.SlotCraftingResult; +import calclavia.lib.prefab.slot.SlotSpecific; +import calclavia.lib.prefab.slot.SlotWatched; + +public class ContainerImprinter extends Container implements ISlotWatcher +{ + public InventoryPlayer inventoryPlayer; + public TileImprinter tileEntity; + + public ContainerImprinter(InventoryPlayer inventoryPlayer, TileImprinter tileEntity) + { + this.tileEntity = tileEntity; + this.tileEntity.container = this; + this.inventoryPlayer = inventoryPlayer; + + /** Crafting Matrix */ + for (int x = 0; x < 3; x++) + { + for (int y = 0; y < 3; y++) + { + this.addSlotToContainer(new SlotWatched(this.tileEntity, y + x * 3, 9 + y * 18, 16 + x * 18, this)); + } + } + + // Imprint Input for Imprinting + this.addSlotToContainer(new SlotSpecific(this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START, 68, 34, ItemBlockFilter.class)); + // Item to be imprinted + this.addSlotToContainer(new SlotWatched(this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START + 1, 92, 34, this)); + // Result of Crafting/Imprinting + this.addSlotToContainer(new SlotCraftingResult(this.tileEntity, this, this.tileEntity, TileImprinter.IMPRINTER_MATRIX_START + 2, 148, 34)); + + // Imprinter Inventory + for (int ii = 0; ii < 2; ii++) + { + for (int i = 0; i < 9; i++) + { + this.addSlotToContainer(new SlotWatched(this.tileEntity, (i + ii * 9) + TileImprinter.INVENTORY_START, 8 + i * 18, 80 + ii * 18, this)); + } + } + + // Player Inventory + int var3; + + for (var3 = 0; var3 < 3; ++var3) + { + for (int var4 = 0; var4 < 9; ++var4) + { + this.addSlotToContainer(new SlotWatched(inventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 120 + var3 * 18, this)); + } + } + + for (var3 = 0; var3 < 9; ++var3) + { + this.addSlotToContainer(new SlotWatched(inventoryPlayer, var3, 8 + var3 * 18, 178, this)); + } + + this.tileEntity.openChest(); + } + + @Override + public void onContainerClosed(EntityPlayer par1EntityPlayer) + { + super.onContainerClosed(par1EntityPlayer); + this.tileEntity.closeChest(); + } + + @Override + public boolean canInteractWith(EntityPlayer player) + { + return this.tileEntity.isUseableByPlayer(player); + } + + /** Called to transfer a stack from one inventory to the other eg. when shift clicking. */ + @Override + public ItemStack transferStackInSlot(EntityPlayer player, int slot) + { + ItemStack copyStack = null; + Slot slotObj = (Slot) this.inventorySlots.get(slot); + + if (slotObj != null && slotObj.getHasStack()) + { + ItemStack slotStack = slotObj.getStack(); + copyStack = slotStack.copy(); + + if (slot == TileImprinter.INVENTORY_START - 1) + { + // Prevents filter from being duplicated + this.tileEntity.setInventorySlotContents(TileImprinter.INVENTORY_START - 1, null); + } + + if (slot > this.tileEntity.getSizeInventory() - 1) + { + if (this.getSlot(TileImprinter.IMPRINTER_MATRIX_START).isItemValid(slotStack)) + { + if (!this.mergeItemStack(slotStack, TileImprinter.IMPRINTER_MATRIX_START, TileImprinter.IMPRINTER_MATRIX_START + 1, true)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, TileImprinter.INVENTORY_START, this.tileEntity.getSizeInventory(), false)) + { + return null; + } + } + else if (!this.mergeItemStack(slotStack, this.tileEntity.getSizeInventory(), this.tileEntity.getSizeInventory() + 36, false)) + { + return null; + } + + if (slotStack.stackSize == 0) + { + slotObj.putStack(null); + } + else + { + slotObj.onSlotChanged(); + } + + if (slotStack.stackSize == copyStack.stackSize) + { + return null; + } + + slotObj.onPickupFromSlot(player, slotStack); + } + + this.slotContentsChanged(slot); + return copyStack; + } + + @Override + public void slotContentsChanged(int slot) + { + this.tileEntity.onInventoryChanged(); + this.detectAndSendChanges(); + } +} diff --git a/src/main/java/resonantinduction/archaic/engineering/ItemBlockFilter.java b/src/main/java/resonantinduction/archaic/imprint/ItemBlockFilter.java similarity index 98% rename from src/main/java/resonantinduction/archaic/engineering/ItemBlockFilter.java rename to src/main/java/resonantinduction/archaic/imprint/ItemBlockFilter.java index b20322748..de86adedb 100644 --- a/src/main/java/resonantinduction/archaic/engineering/ItemBlockFilter.java +++ b/src/main/java/resonantinduction/archaic/imprint/ItemBlockFilter.java @@ -1,4 +1,4 @@ -package resonantinduction.archaic.engineering; +package resonantinduction.archaic.imprint; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/resonantinduction/archaic/engineering/TileImprinter.java b/src/main/java/resonantinduction/archaic/imprint/TileImprinter.java similarity index 99% rename from src/main/java/resonantinduction/archaic/engineering/TileImprinter.java rename to src/main/java/resonantinduction/archaic/imprint/TileImprinter.java index 99f7718ea..bad6468d8 100644 --- a/src/main/java/resonantinduction/archaic/engineering/TileImprinter.java +++ b/src/main/java/resonantinduction/archaic/imprint/TileImprinter.java @@ -1,4 +1,4 @@ -package resonantinduction.archaic.engineering; +package resonantinduction.archaic.imprint; import java.util.ArrayList; import java.util.List; @@ -44,7 +44,7 @@ public class TileImprinter extends TileAdvanced implements ISidedInventory, IArm public static int[] inventorySlots; /** The containing currently used by the imprinter. */ - public ContainerEngineering container; + public ContainerImprinter container; /** Is the current crafting result a result of an imprint? */ private boolean isImprinting = false; diff --git a/src/main/java/resonantinduction/core/prefab/block/BlockImprintable.java b/src/main/java/resonantinduction/core/prefab/block/BlockImprintable.java index 20e96f5f6..1bb655969 100644 --- a/src/main/java/resonantinduction/core/prefab/block/BlockImprintable.java +++ b/src/main/java/resonantinduction/core/prefab/block/BlockImprintable.java @@ -9,7 +9,7 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import resonantinduction.api.IFilterable; -import resonantinduction.archaic.engineering.ItemBlockFilter; +import resonantinduction.archaic.imprint.ItemBlockFilter; import resonantinduction.core.prefab.tile.TileEntityFilterable; /** diff --git a/src/main/java/resonantinduction/core/prefab/tile/TileEntityFilterable.java b/src/main/java/resonantinduction/core/prefab/tile/TileEntityFilterable.java index 7315bdee9..7fbf105a6 100644 --- a/src/main/java/resonantinduction/core/prefab/tile/TileEntityFilterable.java +++ b/src/main/java/resonantinduction/core/prefab/tile/TileEntityFilterable.java @@ -6,7 +6,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.ForgeDirection; import resonantinduction.api.IFilterable; -import resonantinduction.archaic.engineering.ItemBlockFilter; +import resonantinduction.archaic.imprint.ItemBlockFilter; import calclavia.lib.prefab.tile.IRotatable; public abstract class TileEntityFilterable extends TileAssembly implements IRotatable, IFilterable diff --git a/src/main/java/resonantinduction/core/render/RenderImprintable.java b/src/main/java/resonantinduction/core/render/RenderImprintable.java index 55f0744ae..1f8d9f48b 100644 --- a/src/main/java/resonantinduction/core/render/RenderImprintable.java +++ b/src/main/java/resonantinduction/core/render/RenderImprintable.java @@ -8,7 +8,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MovingObjectPosition; -import resonantinduction.archaic.engineering.ItemBlockFilter; +import resonantinduction.archaic.imprint.ItemBlockFilter; import resonantinduction.core.prefab.tile.TileEntityFilterable; import calclavia.lib.render.RenderUtility; import cpw.mods.fml.relauncher.Side; diff --git a/src/main/resources/assets/resonantinduction/languages/en_US.properties b/src/main/resources/assets/resonantinduction/languages/en_US.properties index 44338e711..5c6f1cbf8 100644 --- a/src/main/resources/assets/resonantinduction/languages/en_US.properties +++ b/src/main/resources/assets/resonantinduction/languages/en_US.properties @@ -12,6 +12,7 @@ fluid.mixture=Mixture ### Archaic Module ## Transport tile.resonantinduction\:crate.name=Crate +tile.resonantinduction\:engineeringTable.name=Engineering Table ### Mechanical Module ## Transport