From 883de2d8bb5c3dea747cad0744d675dd5dfc48fa Mon Sep 17 00:00:00 2001 From: asiekierka Date: Sat, 13 Dec 2014 10:20:44 +0100 Subject: [PATCH] fix #2298, add list tooltips, fix inserting lists inside lists, fix list stackability --- .../assets/buildcraft/lang/en_US.lang | 2 ++ common/buildcraft/core/ItemList.java | 5 ++++ common/buildcraft/core/gui/AdvancedSlot.java | 3 ++- common/buildcraft/core/gui/ContainerList.java | 2 +- common/buildcraft/core/gui/GuiList.java | 23 ++++++++++++++++--- 5 files changed, 30 insertions(+), 5 deletions(-) diff --git a/buildcraft_resources/assets/buildcraft/lang/en_US.lang b/buildcraft_resources/assets/buildcraft/lang/en_US.lang index 5b2f2989..424a99d9 100644 --- a/buildcraft_resources/assets/buildcraft/lang/en_US.lang +++ b/buildcraft_resources/assets/buildcraft/lang/en_US.lang @@ -159,6 +159,8 @@ gui.heat=Heat gui.assemblyRate=Energy Rate gui.assemblyCurrentRequired=Energy Required gui.clickcraft=-Click to Craft- +gui.list.metadata=Accept Variations +gui.list.oredict=Accept Equivalents gui.pipes.emerald.title=Filters gui.pipes.emerald.blocking=Blocking gui.pipes.emerald.blocking.tip=Extraction is blocked if one element in filter is missing diff --git a/common/buildcraft/core/ItemList.java b/common/buildcraft/core/ItemList.java index c1005dcb..058c3853 100644 --- a/common/buildcraft/core/ItemList.java +++ b/common/buildcraft/core/ItemList.java @@ -209,6 +209,11 @@ public class ItemList extends ItemBuildCraft { } } + public ItemList() { + super(); + setMaxStackSize(1); + } + @Override public IIcon getIconIndex(ItemStack stack) { if (NBTUtils.getItemData(stack).hasKey("written")) { diff --git a/common/buildcraft/core/gui/AdvancedSlot.java b/common/buildcraft/core/gui/AdvancedSlot.java index 415144b7..15e3855f 100755 --- a/common/buildcraft/core/gui/AdvancedSlot.java +++ b/common/buildcraft/core/gui/AdvancedSlot.java @@ -15,6 +15,7 @@ import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.StatCollector; import buildcraft.core.DefaultProps; @@ -38,7 +39,7 @@ public abstract class AdvancedSlot { } public final void drawTooltip(GuiAdvancedInterface gui, int x, int y) { - String s = getDescription(); + String s = StatCollector.translateToLocal(getDescription()); if (s != null) { gui.drawTooltip(s, x, y); diff --git a/common/buildcraft/core/gui/ContainerList.java b/common/buildcraft/core/gui/ContainerList.java index 6748673f..d34d1ee2 100755 --- a/common/buildcraft/core/gui/ContainerList.java +++ b/common/buildcraft/core/gui/ContainerList.java @@ -54,7 +54,7 @@ public class ContainerList extends BuildCraftContainer implements ICommandReceiv ItemList.saveLine(player.getCurrentEquippedItem(), lines[lineIndex], lineIndex); if (player.worldObj.isRemote) { - BuildCraftCore.instance.sendToServer(new PacketCommand(this, "switchButton", new CommandWriter() { + BuildCraftCore.instance.sendToServer(new PacketCommand(this, "setStack", new CommandWriter() { public void write(ByteBuf data) { data.writeByte(lineIndex); data.writeByte(slotIndex); diff --git a/common/buildcraft/core/gui/GuiList.java b/common/buildcraft/core/gui/GuiList.java index 9328dfb1..ad6da86b 100755 --- a/common/buildcraft/core/gui/GuiList.java +++ b/common/buildcraft/core/gui/GuiList.java @@ -10,6 +10,7 @@ package buildcraft.core.gui; import net.minecraft.client.gui.GuiTextField; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ResourceLocation; @@ -76,12 +77,19 @@ public class GuiList extends GuiAdvancedInterface { public int line; public int kind; + private String desc; - public Button(GuiAdvancedInterface gui, int x, int y, int iLine, int iKind) { + @Override + public String getDescription() { + return desc; + } + + public Button(GuiAdvancedInterface gui, int x, int y, int iLine, int iKind, String iDesc) { super(gui, x, y); line = iLine; kind = iKind; + desc = iDesc; } } @@ -99,8 +107,8 @@ public class GuiList extends GuiAdvancedInterface { slots.add(new SecondarySlot(this, 44 + sx * 18, 31 + sy * 18, sy, sx)); } - slots.add(new Button(this, 8, 31 + sy * 18, sy, 0)); - slots.add(new Button(this, 26, 31 + sy * 18, sy, 1)); + slots.add(new Button(this, 8, 31 + sy * 18, sy, 0, "gui.list.metadata")); + slots.add(new Button(this, 26, 31 + sy * 18, sy, 1, "gui.list.oredict")); } player = iPlayer; @@ -166,10 +174,19 @@ public class GuiList extends GuiAdvancedInterface { drawTooltipForSlotAt(par1, par2); } + private boolean isCarryingList() { + ItemStack stack = mc.thePlayer.inventory.getItemStack(); + return (stack != null && stack.getItem() != null && stack.getItem() instanceof ItemList); + } + @Override protected void mouseClicked(int x, int y, int b) { super.mouseClicked(x, y, b); + if (isCarryingList()) { + return; + } + AdvancedSlot slot = getSlotAtLocation(x, y); ContainerList container = (ContainerList) getContainer();