Skip to content

Commit

Permalink
fishtrap: Exposed Fishtrap slots for hopper etc
Browse files Browse the repository at this point in the history
Items can ONLY be INSERTED into the bait slot
Items can ONLY be EXTRACTED from the loot/trap slots
  • Loading branch information
IceDragon200 committed Dec 5, 2016
1 parent 210deb3 commit f150ace
Showing 1 changed file with 36 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@

public class TileEntityFishTrap extends GrcTileInventoryBase implements IInteractionObject
{
private static final int[] trapSlots = new int[] {0,1,2,3,4,5};
private static final int[] baitSlots = new int[] {6};
private static final int[] TRAP_SLOTS = new int[] {0,1,2,3,4,5};
private static final int[] BAIT_SLOTS = new int[] {6};
private static final int[] ACCESSIBLE_SLOTS = new int[] {0,1,2,3,4,5,6};
public InventorySlice trapInventory;
public InventorySlice baitInventory;

public TileEntityFishTrap()
{
super();
this.trapInventory = new InventorySlice(this, trapSlots);
this.baitInventory = new InventorySlice(this, baitSlots);
this.trapInventory = new InventorySlice(this, TRAP_SLOTS);
this.baitInventory = new InventorySlice(this, BAIT_SLOTS);
}

@Override
Expand All @@ -73,6 +74,34 @@ public GrcInternalInventory createInventory()
return new GrcInternalInventory(this, 7);
}

@Override
public boolean canInsertItem(int slot, ItemStack stack, int facing)
{
// only insert into the bait slot
if (slot == 6) {
return super.canInsertItem(slot, stack, facing);
} else {
return false;
}
}

@Override
public boolean canExtractItem(int slot, ItemStack stack, int facing)
{
// only extract from the loot/trap slots
if (slot < 6) {
return super.canExtractItem(slot, stack, facing);
} else {
return false;
}
}

@Override
public int[] getAccessibleSlotsFromSide(int facing)
{
return ACCESSIBLE_SLOTS;
}

/**
* Called after a successful catch, this will remove an item from the stack
* of provided bait
Expand Down Expand Up @@ -106,17 +135,17 @@ public float applyBaitModifier(float f)

public int getBaitInventoryOffset()
{
return baitSlots[0];
return BAIT_SLOTS[0];
}

public int getTrapInventorySize()
{
return trapSlots.length;
return TRAP_SLOTS.length;
}

public int getBaitInventorySize()
{
return baitSlots.length;
return BAIT_SLOTS.length;
}

/**
Expand Down

0 comments on commit f150ace

Please sign in to comment.