Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ContainerDeciInventory extends Container {
- private static final String __OBFID = "CL_00001754";
- private final EntityPlayer thePlayer;
- public InventoryDeci invDeci;
- public InventoryGeneric invCorpse;
- /**
- * Determines if inventory manipulation should be handled.
- */
- public boolean isLocalWorld;
- public int w;
- public int h;
- public int type;
- ItemStack prevIt = null;
- private RagdollCorpse corpse;
- private int backslots = 0;
- public ContainerDeciInventory(final InventoryPlayer p_i1819_1_, EntityPlayer p_i1819_3_, int cid, int type) {
- this(p_i1819_1_, false, p_i1819_3_, 0, 0, cid, type);
- }
- public ContainerDeciInventory(final InventoryPlayer p_i1819_1_, boolean p_i1819_2_, EntityPlayer player, int width, int height, int cid, int type) {
- this.thePlayer = player;
- /* if (cid > -1) {
- if (cid < RagdollCorpse.pcorpseList.size()) {
- corpse = RagdollCorpse.pcorpseList.get(cid);
- }
- }*/
- initContainer(p_i1819_1_, p_i1819_2_, player, width, height, type);
- }
- public void initContainer(final InventoryPlayer p_i1819_1_, boolean p_i1819_2_, EntityPlayer player, int width, int height, int type) {
- if (width == -1) {
- return;
- }
- this.type = type;
- inventorySlots.clear();
- this.inventoryItemStacks.clear();
- this.isLocalWorld = p_i1819_2_;
- invDeci = new InventoryDeci(this, player);
- w = width;
- h = height;
- // this.addSlotToContainer(new SlotCrafting(p_i1819_1_.player, this.craftMatrix, this.craftResult, 0, 144, 36));
- int i;
- int j;
- /* for (i = 0; i < 2; ++i)
- {
- for (j = 0; j < 2; ++j)
- {
- this.addSlotToContainer(new Slot(this.craftMatrix, j + i * 2, 88 + j * 18, 26 + i * 18));
- }
- }*/
- // 120, height / 2 - 65;
- for (i = 0; i < 4; ++i) {
- final int k = i;
- this.addSlotToContainer(new Slot(p_i1819_1_, p_i1819_1_.getSizeInventory() - 1 - i, 121, (height / 2) - 64 + i * 20) {
- private static final String __OBFID = "CL_00001755";
- /**
- * Returns the maximum stack size for a given slot (usually the same as getInventoryStackLimit(), but 1
- * in the case of armor slots)
- */
- public int getSlotStackLimit() {
- return 1;
- }
- /**
- * Check if the stack is a valid item for this slot. Always true beside for the armor slots.
- */
- public boolean isItemValid(ItemStack stack) {
- if (stack == null) return false;
- return stack.getItem().isValidArmor(stack, k, thePlayer);
- }
- });
- }
- for (i = 0; i < 3; ++i) {
- for (j = 0; j < 9; ++j) {
- this.addSlotToContainer(new Slot(p_i1819_1_, j + (i + 1) * 9, ((width / 2) - (176 / 2) + 8) + j * 18, (height - 107) + i * 18));
- }
- }
- for (i = 0; i < 9; ++i) {
- this.addSlotToContainer(new Slot(p_i1819_1_, i, ((width / 2) - (176 / 2) + 8) + i * 18, height - 39));
- }
- CommonPlayerData data = CommonPlayerData.get(player);
- // this.onCraftMatrixChanged(this.craftMatrix);
- int backPosX = width / 2 + 200 - 20;
- int backPosY = height / 2 - 85;
- int rows = (((data.getBackpack() != null && data.getBackpack().getItem() instanceof ItemBackpack ? ((ItemBackpack) data.getBackpack().getItem()).capacity : 0) + 2) / 3) - 1;
- int row = 0;
- backPosX -= (rows * 20) + 20;
- invDeci.editing = true;
- this.addSlotToContainer(new SlotRestrictable(invDeci, 0, backPosX, backPosY));
- if (data.getBackpack() != null)
- invDeci.setInventorySlotContents(0, data.getBackpack());
- this.addSlotToContainer(new SlotRestrictable(invDeci, 1, 100 + 1, height / 2 - 65 + 1));
- this.addSlotToContainer(new SlotRestrictable(invDeci, 2, 140 + 1, height / 2 - 65 + (20) + 1));
- if (data.getMask() != null)
- invDeci.setInventorySlotContents(1, data.getMask());
- if (data.getVest() != null)
- invDeci.setInventorySlotContents(2, data.getVest());
- invDeci.editing = false;
- if (data.getBackpack() != null && data.getBackpack().getItem() instanceof ItemBackpack) {
- ItemBackpack pack = (ItemBackpack) data.getBackpack().getItem();
- InventoryBackpack invBackpack = new InventoryBackpack(data, this);
- invBackpack.adding = true;
- backslots = pack.capacity;
- int y = 0;
- for (i = 0; i < pack.capacity; i++) {
- int xp = width / 2 + 200 - 20;
- int yp = height / 2 - 85;
- this.addSlotToContainer(new SlotRestrictable(invBackpack, i, xp - (20 * (rows - row)), yp + (y * 20)));
- invBackpack.setInventorySlotContents(i, pack.getStackInSlot(data.getBackpack(), i));
- if (y == 2) {
- row++;
- y = 0;
- } else {
- y++;
- }
- }
- invBackpack.adding = false;
- //invBackpack.markDirty();
- }
- //data.openCorpse.data = data;
- if (data.getOpenCorpse() != null && type == 1) {
- data.getOpenCorpse().adding = true;
- // invCorpse = new InventoryGeneric(corpse, corpse.getSizeInventory());
- rows = (data.getOpenCorpse().getSizeInventory() / 2) - 1;
- row = 0;
- int y = 0;
- for (i = 0; i < data.getOpenCorpse().getSizeInventory(); i++) {
- int xp = width / 2 + 280 - 20;
- int yp = height / 2 + 15;
- this.addSlotToContainer(new Slot(data.getOpenCorpse(), i, xp - (20 * (rows - row)), yp + (y * 20)));
- //invCorpse.setInventorySlotContentsNo(i, corpse.getStackInSlot(i));
- if (row == 3) {
- y++;
- row = 0;
- } else {
- row++;
- }
- }
- data.getOpenCorpse().adding = false;
- }
- if (data.getOpenLoot() != null && type == 2) {
- rows = (data.getOpenLoot().getSizeInventory() / 2) - 1;
- row = 0;
- int y = 0;
- for (i = 0; i < data.getOpenLoot().getSizeInventory(); i++) {
- int xp = width / 2 - 200;
- int yp = height / 2 + 55;
- this.addSlotToContainer(new Slot(data.getOpenLoot(), i, xp + (20 * (row)), yp + (y * 20)));
- //invCorpse.setInventorySlotContents(i, corpse.getStackInSlot(i));
- if (y == 3) {
- row++;
- y = 0;
- } else {
- y++;
- }
- }
- }
- }
- /**
- * Callback for when the crafting matrix is changed.
- */
- public void onCraftMatrixChanged(IInventory p_75130_1_) {
- //this.craftResult.setInventorySlotContents(0, CraftingManager.getInstance().findMatchingRecipe(this.craftMatrix, this.thePlayer.worldObj));
- }
- /**
- * Called when the container is closed.
- */
- public void onContainerClosed(EntityPlayer player) {
- super.onContainerClosed(player);
- // p_75134_1_.inventoryContainer.detectAndSendChanges();
- /* for (int i = 0; i < 4; ++i)
- {
- ItemStack itemstack = this.craftMatrix.getStackInSlotOnClosing(i);
- if (itemstack != null)
- {
- p_75134_1_.dropPlayerItemWithRandomChoice(itemstack, false);
- }
- }
- this.craftResult.setInventorySlotContents(0, (ItemStack)null);*/
- }
- public boolean canInteractWith(EntityPlayer player) {
- return true;
- }
- /**
- * Take a stack from the specified inventory slot.
- */
- public ItemStack transferStackInSlot(EntityPlayer player, int index) {
- return null;
- /* ItemStack itemstack = null;
- Slot slot = (Slot) this.inventorySlots.get(index);
- if (slot != null && slot.getHasStack()) {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();*/
- /* if (index == 0)
- {
- if (!this.mergeItemStack(itemstack1, 9, 45, true))
- {
- return null;
- }
- slot.onSlotChange(itemstack1, itemstack);
- }*/
- /* else if (index >= 1 && index < 5)
- {
- if (!this.mergeItemStack(itemstack1, 9, 45, false))
- {
- return null;
- }
- }
- else if (index >= 5 && index < 9)
- {
- if (!this.mergeItemStack(itemstack1, 9, 45, false))
- {
- return null;
- }
- }*/
- /* else */
- /* if (itemstack.getItem() instanceof ItemArmor && !((Slot) this.inventorySlots.get(((ItemArmor) itemstack.getItem()).armorType)).getHasStack()) {
- int j = ((ItemArmor) itemstack.getItem()).armorType;
- if (!this.mergeItemStack(itemstack1, j, j + 1, false)) {
- return null;
- }
- } else if (index < 4) {
- if (!this.mergeItemStack(itemstack1, 4, 4 + 9, false)) {
- return null;
- }
- } else if (index > 4 + 9) {
- if (!this.mergeItemStack(itemstack1, 4, 4 + 9, false)) {
- return null;
- }
- }
- /*else if (index >= 9 && index < 36)
- {
- if (!this.mergeItemStack(itemstack1, 36, 45, false))
- {
- return null;
- }
- }
- else if (index >= 36 && index < 45)
- {
- if (!this.mergeItemStack(itemstack1, 9, 36, false))
- {
- return null;
- }
- }
- else if (!this.mergeItemStack(itemstack1, 9, 45, false))
- {
- return null;
- }*/
- /* if (itemstack1.stackSize == 0) {
- slot.putStack((ItemStack) null);
- } else {
- slot.onSlotChanged();
- }
- if (itemstack1.stackSize == itemstack.stackSize) {
- return null;
- }
- slot.onPickupFromSlot(player, itemstack1);
- }*/
- //return itemstack;
- }
- public boolean func_94530_a(ItemStack p_94530_1_, Slot p_94530_2_) {
- return /*p_94530_2_.inventory != this.craftResult && */super.func_94530_a(p_94530_1_, p_94530_2_);
- }
- /**
- * Handles slot click. Args : slotId, clickedButton, mode (0 = basic click, 1 = shift click, 2 = Hotbar, 3 =
- * pickBlock, 4 = Drop, 5 = ?, 6 = Double click), player
- *
- * @param slotId Will be either the slot id in the current Container or -999 if dragging
- * @param mode 0 for basic click, 1 for shift-click, 2 for hotbar, 3 for pickBlock, 4 for drop, 5 for item
- * distribution drag, 6 for double click
- */
- public ItemStack slotClick(int slotId, int clickedButton, int mode, EntityPlayer player) {
- ItemStack itemstack = super.slotClick(slotId, clickedButton, mode, player);
- if (player.inventory.getItemStack() != prevIt && !player.worldObj.isRemote && slotId > 16 && slotId < 16 + backslots) {
- Decimation.mainNetworkChannel.sendTo(new Message_PInv_Stack(player.inventory.getItemStack()), (EntityPlayerMP) player);
- }
- return itemstack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement