Skip to content

Instantly share code, notes, and snippets.

@DiabolicaTrix
Created June 25, 2018 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DiabolicaTrix/b162d609e1244316fcb1d126546fe81f to your computer and use it in GitHub Desktop.
Save DiabolicaTrix/b162d609e1244316fcb1d126546fe81f to your computer and use it in GitHub Desktop.
package xyz.diabolicatrixlab.showcasemod.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
import xyz.diabolicatrixlab.showcasemod.tileentity.TileEntityShowcase;
public class ContainerShowcase extends Container {
private TileEntityShowcase te;
public ContainerShowcase(IInventory playerInv, TileEntityShowcase te) {
this.te = te;
this.addSlots();
this.addInventorySlots(playerInv);
}
@Override
public boolean canInteractWith(EntityPlayer playerIn) {
return te.canInteractWith(playerIn);
}
private void addInventorySlots(IInventory inv){
for(int row = 0; row < 3; row++){
for(int col = 0; col < 9; col++){
int x = 8 + col * 18;
int y = 101 + row * 18;
this.addSlotToContainer(new Slot(inv, col + row * 9 + 10, x, y));
}
}
for(int col = 0; col < 9; col++){
int x = 8 + col * 18;
int y = 89 + 70;
this.addSlotToContainer(new Slot(inv, col, x, y));
}
}
private void addSlots()
{
IItemHandler itemHandler = this.te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
this.addSlotToContainer(new SlotShowcase(itemHandler, te, 0, 112, 21));
}
@Override
public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
return ItemStack.EMPTY;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment