From adb64232e7866613d3e3736afdc1f7d8ccba2b07 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 12 Jul 2015 01:22:47 +0200 Subject: [PATCH] Fixed a Bug with Number Key Slot Swapping and the Drill being movable, added Armor Slots to the Energizer & Enervator --- .../inventory/ContainerDrill.java | 8 ++++++ .../inventory/ContainerEnergizer.java | 27 +++++++++++++++++- .../inventory/ContainerEnervator.java | 27 +++++++++++++++++- .../inventory/GuiHandler.java | 8 +++--- .../inventory/gui/GuiEnergizer.java | 4 +-- .../inventory/gui/GuiEnervator.java | 4 +-- .../inventory/slot/SlotImmovable.java | 11 ++++++- .../textures/gui/guiEnergizer.png | Bin 1923 -> 1962 bytes 8 files changed, 78 insertions(+), 11 deletions(-) diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java index 5d5281aa7..b8a3d30dc 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerDrill.java @@ -62,6 +62,14 @@ public class ContainerDrill extends Container{ super.onContainerClosed(player); } + @Override + public ItemStack slotClick(int par1, int par2, int par3, EntityPlayer player){ + //par3 appears to be the type of clicking + //par3 == 2 appears to be one of the number keys being hit + if(par3 == 2 && par2 == inventory.currentItem) return null; + else return super.slotClick(par1, par2, par3, player); + } + @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ final int inventoryStart = 5; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnergizer.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnergizer.java index e58c188b3..7b88403a5 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnergizer.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnergizer.java @@ -1,6 +1,8 @@ package ellpeck.actuallyadditions.inventory; import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.inventory.slot.SlotOutput; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityEnergizer; @@ -9,15 +11,18 @@ 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.ItemArmor; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; @InventoryContainer public class ContainerEnergizer extends Container{ private TileEntityEnergizer energizer; - public ContainerEnergizer(InventoryPlayer inventory, TileEntityBase tile){ + public ContainerEnergizer(EntityPlayer player, TileEntityBase tile){ this.energizer = (TileEntityEnergizer)tile; + InventoryPlayer inventory = player.inventory; this.addSlotToContainer(new Slot(this.energizer, 0, 76, 73)); this.addSlotToContainer(new SlotOutput(this.energizer, 1, 76, 42)); @@ -30,6 +35,25 @@ public class ContainerEnergizer extends Container{ for (int i = 0; i < 9; i++){ this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } + final EntityPlayer finalPlayer = player; + for(int i = 0; i < 4; ++i){ + final int finalI = i; + this.addSlotToContainer(new Slot(inventory, inventory.getSizeInventory()-1-i, 102, 19+i*18){ + @Override + public int getSlotStackLimit(){ + return 1; + } + @Override + public boolean isItemValid(ItemStack stack){ + return stack != null && stack.getItem().isValidArmor(stack, finalI, finalPlayer); + } + @Override + @SideOnly(Side.CLIENT) + public IIcon getBackgroundIconIndex(){ + return ItemArmor.func_94602_b(finalI); + } + }); + } } @Override @@ -37,6 +61,7 @@ public class ContainerEnergizer extends Container{ return this.energizer.isUseableByPlayer(player); } + //TODO Armor Shift-Clicking @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ final int inventoryStart = 2; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnervator.java b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnervator.java index c66bb6d9f..529d8c2df 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnervator.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/ContainerEnervator.java @@ -1,6 +1,8 @@ package ellpeck.actuallyadditions.inventory; import cofh.api.energy.IEnergyContainerItem; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; import ellpeck.actuallyadditions.inventory.slot.SlotOutput; import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityEnervator; @@ -9,15 +11,18 @@ 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.ItemArmor; import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; @InventoryContainer public class ContainerEnervator extends Container{ private TileEntityEnervator enervator; - public ContainerEnervator(InventoryPlayer inventory, TileEntityBase tile){ + public ContainerEnervator(EntityPlayer player, TileEntityBase tile){ this.enervator = (TileEntityEnervator)tile; + InventoryPlayer inventory = player.inventory; this.addSlotToContainer(new Slot(this.enervator, 0, 76, 73)); this.addSlotToContainer(new SlotOutput(this.enervator, 1, 76, 42)); @@ -30,6 +35,25 @@ public class ContainerEnervator extends Container{ for (int i = 0; i < 9; i++){ this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155)); } + final EntityPlayer finalPlayer = player; + for(int i = 0; i < 4; ++i){ + final int finalI = i; + this.addSlotToContainer(new Slot(inventory, inventory.getSizeInventory()-1-i, 102, 19+i*18){ + @Override + public int getSlotStackLimit(){ + return 1; + } + @Override + public boolean isItemValid(ItemStack stack){ + return stack != null && stack.getItem().isValidArmor(stack, finalI, finalPlayer); + } + @Override + @SideOnly(Side.CLIENT) + public IIcon getBackgroundIconIndex(){ + return ItemArmor.func_94602_b(finalI); + } + }); + } } @Override @@ -37,6 +61,7 @@ public class ContainerEnervator extends Container{ return this.enervator.isUseableByPlayer(player); } + //TODO Armor Shift-Clicking @Override public ItemStack transferStackInSlot(EntityPlayer player, int slot){ final int inventoryStart = 2; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java index 5319aee9f..a174cb044 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/GuiHandler.java @@ -57,9 +57,9 @@ public class GuiHandler implements IGuiHandler{ case DRILL_ID: return new ContainerDrill(entityPlayer.inventory); case ENERGIZER_ID: - return new ContainerEnergizer(entityPlayer.inventory, tile); + return new ContainerEnergizer(entityPlayer, tile); case ENERVATOR_ID: - return new ContainerEnervator(entityPlayer.inventory, tile); + return new ContainerEnervator(entityPlayer, tile); default: return null; } @@ -111,9 +111,9 @@ public class GuiHandler implements IGuiHandler{ case DRILL_ID: return new GuiDrill(entityPlayer.inventory); case ENERGIZER_ID: - return new GuiEnergizer(entityPlayer.inventory, tile); + return new GuiEnergizer(entityPlayer, tile); case ENERVATOR_ID: - return new GuiEnervator(entityPlayer.inventory, tile); + return new GuiEnervator(entityPlayer, tile); default: return null; } diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnergizer.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnergizer.java index 9fd9976eb..65ed62640 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnergizer.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnergizer.java @@ -7,7 +7,7 @@ import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityEnergizer; import ellpeck.actuallyadditions.util.AssetUtil; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -20,7 +20,7 @@ public class GuiEnergizer extends GuiContainer{ private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer"); - public GuiEnergizer(InventoryPlayer inventory, TileEntityBase tile){ + public GuiEnergizer(EntityPlayer inventory, TileEntityBase tile){ super(new ContainerEnergizer(inventory, tile)); this.energizer = (TileEntityEnergizer)tile; this.xSize = 176; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnervator.java b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnervator.java index e6f367f34..4fdf21482 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnervator.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/gui/GuiEnervator.java @@ -7,7 +7,7 @@ import ellpeck.actuallyadditions.tile.TileEntityBase; import ellpeck.actuallyadditions.tile.TileEntityEnervator; import ellpeck.actuallyadditions.util.AssetUtil; import net.minecraft.client.gui.inventory.GuiContainer; -import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; @@ -20,7 +20,7 @@ public class GuiEnervator extends GuiContainer{ private static final ResourceLocation resLoc = AssetUtil.getGuiLocation("guiEnergizer"); - public GuiEnervator(InventoryPlayer inventory, TileEntityBase tile){ + public GuiEnervator(EntityPlayer inventory, TileEntityBase tile){ super(new ContainerEnervator(inventory, tile)); this.enervator = (TileEntityEnervator)tile; this.xSize = 176; diff --git a/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotImmovable.java b/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotImmovable.java index 5a84544b4..5d0016271 100644 --- a/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotImmovable.java +++ b/src/main/java/ellpeck/actuallyadditions/inventory/slot/SlotImmovable.java @@ -11,6 +11,16 @@ public class SlotImmovable extends Slot{ super(inventory, id, x, y); } + @Override + public void putStack(ItemStack stack){ + + } + + @Override + public ItemStack decrStackSize(int i){ + return null; + } + @Override public boolean canTakeStack(EntityPlayer player){ return false; @@ -20,5 +30,4 @@ public class SlotImmovable extends Slot{ public boolean isItemValid(ItemStack stack){ return false; } - } diff --git a/src/main/resources/assets/actuallyadditions/textures/gui/guiEnergizer.png b/src/main/resources/assets/actuallyadditions/textures/gui/guiEnergizer.png index 621f107cc3a7f5ac85832198bcdded0497e45e41..20e30317247bea277091b041a6b6f59c3eee5221 100644 GIT binary patch delta 580 zcmZqXU&X&6goSG(0|Vbi#yLImwZl2U5~r z%ADzHk({>b!1ce&zh>mV%@n`#b(6KvhTANBW+&E*_AH-i*?af6+8NP=_e~#7gwr=( z{3o9u%z9&Yg3Z~KhV8r+l`}OD++%&5`HX49pdOySNHITPT|-cxF#~NVVVGRki>%bM}TJQv2g5EE_uim@p(>pOAW_{ z*u;j^-)m2xZI{rc`>kIBrkK`9I$(TP8_24?tRxkd+vSBYb^Ol7m z-}PBARg3p5H)N1I!0?~z!_+C(PT8-#9@Kvo{;TUR(eQfrif*MRiU|zcw0Sn<+&5ro zKE#mwBZu*q`gYMs#)!AZY!Tb?U05>W?{A6~6npSz7PmCp4OqZ|f}-LM!=L$&Uq>?S z*|&bjm&YI9zvJjVgTe~DWM4f)eQgx delta 544 zcmZ3*-^{-ugoSGp0|VbCMnhA(?UUnJ)asdDdb&75jjZYKZ`U-c+9ExCkmbby?%mGcl zS^q!Tg*5Dx*5Nmnc<`6u-aR)igYxF5iN}}>4khoYXpoOS_d4S5o~nj;=~L5N8F>;I z%GMmHzr#DN-H<^qfq_{f!EzttjNOS1rEBVdlFS>DSwTkkFcvT}OB`T0{gL;;9bV=& z$zPL!Y8zy=!G`lRa0BJoBKqH1curxq z2lEdc`{$a7=JE&klNs~$tED$F8GH%n+2B{z{_-8;bnasFLrj0>&wg-Gf6 z^@|w(oGY}KXRP~o)8Ny$3Q@jVmF2gYqgpxTTJLh%EIjb`zopr0H=QB AH2?qr