Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import fr.fuulys.valamod.tiles.TileValaniumChest;
- import java.util.List;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.player.InventoryPlayer;
- import net.minecraft.inventory.Container;
- import net.minecraft.inventory.Slot;
- import net.minecraft.item.ItemStack;
- public class ValaniumChestContainer extends Container {
- private TileValaniumChest tile;
- private InventoryPlayer inventory;
- public ValaniumChestContainer(TileValaniumChest tile, InventoryPlayer inventory) {
- this.inventory = inventory;
- this.tile = tile;
- tile.openInventory();
- int i = 0;
- for (i = 0; i < 9; i++) {
- for (int j = 0; j < 12; j++) {
- addSlotToContainer(new Slot(tile, j + i * 12, 12 + j * 18, 8 + i * 18));
- }
- }
- bindPlayerInventory();
- }
- private void bindPlayerInventory() {
- for (int i = 0; i < 3; i++) {
- for (int j = 0; j < 9; j++) {
- addSlotToContainer(new Slot(this.inventory, j + i * 9 + 9, 39 + j * 18, 174 + i * 18));
- }
- }
- int i;
- for (i = 0; i < 9; i++) {
- addSlotToContainer(new Slot(this.inventory, i, 39 + i * 18, 232));
- }
- }
- public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
- ItemStack stack = null;
- Slot slots = (Slot) this.inventorySlots.get(slot);
- if ((slots != null) && (slots.getHasStack())) {
- ItemStack stack1 = slots.getStack();
- stack = stack1.copy();
- if (slot < 112) {
- if (!mergeItemStack(stack1, 112, 148, true)) {
- return null;
- }
- slots.onSlotChange(stack1, stack);
- }
- if (slot >= 112) {
- if (!mergeItemStack(stack1, 0, 108, false)) {
- return null;
- }
- slots.onSlotChange(stack1, stack);
- }
- if (stack1.stackSize == 0) {
- slots.putStack((ItemStack) null);
- } else {
- slots.onSlotChanged();
- }
- if (stack1.stackSize == stack.stackSize) {
- return null;
- }
- slots.onPickupFromSlot(player, stack1);
- }
- return stack;
- }
- public void onContainerClosed(EntityPlayer player) {
- super.onContainerClosed(player);
- this.tile.closeInventory();
- }
- public boolean canInteractWith(EntityPlayer player) {
- return this.tile.isUseableByPlayer(player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement