From 5aa74c5cceec81b7f9b5e50d1e6e2cbb59b1acfb Mon Sep 17 00:00:00 2001 From: HenryLoenwind Date: Wed, 30 Dec 2015 08:23:22 +0100 Subject: [PATCH 1/2] Let background ghost slots hide when their parent slot has an item also honour inherited visible flag even when a parent is set --- .../core/client/gui/widget/GhostBackgroundItemSlot.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/enderio/core/client/gui/widget/GhostBackgroundItemSlot.java b/src/main/java/com/enderio/core/client/gui/widget/GhostBackgroundItemSlot.java index f55bffea..d22dd420 100644 --- a/src/main/java/com/enderio/core/client/gui/widget/GhostBackgroundItemSlot.java +++ b/src/main/java/com/enderio/core/client/gui/widget/GhostBackgroundItemSlot.java @@ -60,7 +60,7 @@ public void putStack(ItemStack stack) { @Override public boolean isVisible() { - return parent != null ? parent.xDisplayPosition >= 0 && parent.yDisplayPosition >= 0 : super.isVisible(); + return parent != null ? parent.xDisplayPosition >= 0 && parent.yDisplayPosition >= 0 && !parent.getHasStack() && super.isVisible() : super.isVisible(); } -} \ No newline at end of file +} From a03b9c3f1aac1cb5a00e5627fa9f632b0535a8fb Mon Sep 17 00:00:00 2001 From: HenryLoenwind Date: Wed, 30 Dec 2015 08:57:32 +0100 Subject: [PATCH 2/2] Allow container classes to handle slots after initialization as they need access to their fields if they have to link slots and background ghost slots --- .../enderio/core/common/ContainerEnder.java | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/enderio/core/common/ContainerEnder.java b/src/main/java/com/enderio/core/common/ContainerEnder.java index 345ddf9a..8237ab96 100644 --- a/src/main/java/com/enderio/core/common/ContainerEnder.java +++ b/src/main/java/com/enderio/core/common/ContainerEnder.java @@ -18,10 +18,10 @@ public class ContainerEnder extends Container { protected Map playerSlotLocations = Maps.newLinkedHashMap(); - protected final int startPlayerSlot; - protected final int endPlayerSlot; - protected final int startHotBarSlot; - protected final int endHotBarSlot; + protected int startPlayerSlot; + protected int endPlayerSlot; + protected int startHotBarSlot; + protected int endHotBarSlot; private final @Nonnull T inv; private final @Nonnull InventoryPlayer playerInv; @@ -38,6 +38,24 @@ public ContainerEnder(InventoryPlayer playerInv, T inv) { this.inv = checkNotNull(inv); this.playerInv = checkNotNull(playerInv); + init(); + } + + /** + * Use this constructor if you need a fully initialized object for your + * addSlots(), e.g. because you need to pass your slots on to your + * createGhostSlots(). You must call init() in your constructor. + */ + public ContainerEnder(boolean iPromiseToCallInitInTheImplementationClassConstructor, InventoryPlayer playerInv, T inv) { + this.inv = checkNotNull(inv); + this.playerInv = checkNotNull(playerInv); + + if (!iPromiseToCallInitInTheImplementationClassConstructor) { + init(); + } + } + + protected void init() { addSlots(playerInv); int x = getPlayerInventoryOffset().x;