Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let background ghost slots hide when their parent slot has an item #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
}
26 changes: 22 additions & 4 deletions src/main/java/com/enderio/core/common/ContainerEnder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public class ContainerEnder<T extends IInventory> extends Container {

protected Map<Slot, Point> 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;
Expand All @@ -38,6 +38,24 @@ public ContainerEnder(InventoryPlayer playerInv, T inv) {
this.inv = checkNotNull(inv);
this.playerInv = checkNotNull(playerInv);

init();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not dupe code, just call this(false, playerInv, inv);

}

/**
* 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 <b>must</b> 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;
Expand Down