Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @author Intektor
- */
- public abstract class AbstractContainer<T extends IInventory> extends Container {
- protected final T inventory;
- protected final EntityPlayer player;
- public AbstractContainer(T inventory, EntityPlayer player) {
- this.inventory = inventory;
- this.player = player;
- addSlots();
- if (inventory instanceof AbstractInventory) {
- ((AbstractInventory) inventory).setContainer(this);
- }
- }
- public T inventory() {
- return inventory;
- }
- protected abstract void addSlots();
- @Override
- public boolean canInteractWith(EntityPlayer player) {
- return inventory.isUseableByPlayer(player);
- }
- @Override
- public void onContainerClosed(EntityPlayer player) {
- inventory.closeInventory(player);
- }
- }
- public ContainerMagazineTable(MagazineTableInventory inventory, EntityPlayer player, BlockPos pos) {
- super(inventory, player);
- this.pos = pos;
- }
- @Override
- protected void addSlots() {
- addSlotToContainer(new Slot(inventory, 0, 24, 35) {
- @Override
- public boolean isItemValid(ItemStack stack) {
- if (stack != null) {
- Item item = stack.getItem();
- return item instanceof ItemGun || item instanceof ItemMagazine;
- }
- return false;
- }
- });
- addSlotToContainer(new SimpleSlot(inventory, 1, 52, 35));
- addSlotToContainer(new SimpleSlot(inventory, 2, 52 + 18, 35));
- addSlotToContainer(new SimpleSlot(inventory, 3, 52 + 36, 35));
- addSlotToContainer(new Slots.SlotNoInput(inventory, 4, 145, 35));
- for (int i = 0; i < 3; ++i) {
- for (int j = 0; j < 9; ++j) {
- this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
- }
- }
- for (int k = 0; k < 9; ++k) {
- this.addSlotToContainer(new Slot(player.inventory, k, 8 + k * 18, 142));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement