Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex)
- {
- ItemStack itemstack = null;
- Slot slot = (Slot) this.inventorySlots.get(slotIndex);
- if (slot != null && slot.getHasStack()) {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- // If item is in TileEntity inventory
- if (slotIndex >= INPUT_CONCRETE_1 && slotIndex <= INPUT_MODIFIER_2 && slotIndex < INV_START) {
- // try to place in player inventory / action bar
- if (!this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, false)) {
- return null;
- }
- slot.onSlotChange(itemstack1, itemstack);
- }
- // Item is in player inventory, try to place in GUI
- else if (slotIndex < HOTBAR_END) {
- // if it's concrete put in Concrete slot
- // if (itemstack1.isItemEqual(new ItemStack(ModBlocks.concrete))) {
- if (BlockTableRecipes.isCraftableBlock(itemstack1)) {
- if (!this.mergeItemStack(itemstack1, INPUT_CONCRETE_1, INPUT_CONCRETE_1 + 1, false)) {
- return null;
- }
- }
- // if it is a recipe material, place in the Modifier input slot
- else if (BlockTableRecipes.isMaterial(itemstack1)) {
- if (!this.mergeItemStack(itemstack1, INPUT_MODIFIER_2, INPUT_MODIFIER_2 + 1, false)) {
- return null;
- }
- }
- // item in player's inventory, but not in action bar
- else if (slotIndex >= INV_START && slotIndex < HOTBAR_START) {
- // place in action bar
- if (!this.mergeItemStack(itemstack1, HOTBAR_START, HOTBAR_END + 1, false)) {
- return null;
- }
- }
- // item in action bar - place in player inventory
- else if (slotIndex >= HOTBAR_START && slotIndex < HOTBAR_END + 1 && !this.mergeItemStack(itemstack1, INV_START, HOTBAR_START, false)) {
- return null;
- }
- }
- // In one of the slots; try to place in player inventory / action bar
- else if (slotIndex >= INPUT_CONCRETE_1 && slotIndex <= INPUT_MODIFIER_2 && !this.mergeItemStack(itemstack1, INV_START, HOTBAR_END + 1, 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement