Files
Gadomancy/src/main/java/makeo/gadomancy/common/containers/ContainerArcanePackager.java
T
Quetz4l 9e4292ef80 infusionClaw (#20)
* infusionClaw
* charging wand from vis net

* bs & sa + nei
* added nei to dependencies

* infusionClaw add desc to lang
2023-05-13 17:40:56 +02:00

128 lines
4.1 KiB
Java

package makeo.gadomancy.common.containers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import makeo.gadomancy.common.blocks.tiles.TileArcanePackager;
/**
* This class is part of the Gadomancy Mod Gadomancy is Open Source and distributed under the GNU LESSER GENERAL PUBLIC
* LICENSE for more read the LICENSE file
* <p/>
* Created by makeo @ 14.11.2015 18:08
*/
public class ContainerArcanePackager extends Container {
public final InventoryPlayer playerInv;
public final IInventory packagerInv;
public ContainerArcanePackager(InventoryPlayer playerInv, IInventory packagerInv) {
this.playerInv = playerInv;
this.packagerInv = packagerInv;
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
this.addSlotToContainer(new Slot(packagerInv, j + i * 3, 16 + 18 * j, 42 + i * 23));
}
}
this.addSlotToContainer(new FilteredSlot(packagerInv, 9, 95, 33));
this.addSlotToContainer(new FilteredSlot(packagerInv, 10, 113, 33));
this.addSlotToContainer(new FilteredSlot(packagerInv, 11, 160, 64));
this.bindPlayerInventory();
}
protected void bindPlayerInventory() {
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(this.playerInv, j + i * 9 + 9, 16 + j * 18, 151 + i * 18));
}
}
for (int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(this.playerInv, i, 16 + i * 18, 209));
}
}
@Override
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();
int size = this.packagerInv.getSizeInventory();
if (slotIndex < size) {
if (!this.mergeItemStack(itemstack1, size, this.inventorySlots.size(), true)) {
return null;
}
} else {
int specialSlot = itemstack1.getItem() == Items.leather ? 9
: itemstack1.getItem() == Items.string ? 10 : -1;
if (specialSlot != -1 && (this.packagerInv.getStackInSlot(specialSlot) == null
|| this.packagerInv.getStackInSlot(specialSlot).stackSize < 64)) {
this.mergeItemStack(itemstack1, specialSlot, specialSlot + 1, false);
if (itemstack1.stackSize == 0) {
slot.putStack(null);
}
return null;
} else if (!this.mergeItemStack(itemstack1, 0, size - 3, false)) {
return null;
}
}
if (itemstack1.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
}
return itemstack;
}
@Override
public boolean enchantItem(EntityPlayer player, int id) {
TileArcanePackager tile = (TileArcanePackager) this.packagerInv;
switch (id) {
case 0:
tile.useEssentia = true;
break;
case 1:
tile.useEssentia = false;
break;
case 2:
tile.autoStart = true;
break;
case 3:
tile.autoStart = false;
break;
case 4:
tile.disguise = true;
break;
case 5:
tile.disguise = false;
break;
}
tile.markForUpdate();
return false;
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
}