mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
73 lines
1.9 KiB
Java
73 lines
1.9 KiB
Java
package com.hbm.inventory.container;
|
|
|
|
import com.hbm.items.ModItems;
|
|
import com.hbm.tileentity.machine.albion.TileEntityPAQuadrupole;
|
|
|
|
import api.hbm.energymk2.IBatteryItem;
|
|
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 ContainerPAQuadrupole extends Container {
|
|
|
|
private TileEntityPAQuadrupole quadrupole;
|
|
|
|
public ContainerPAQuadrupole(InventoryPlayer playerInv, TileEntityPAQuadrupole tile) {
|
|
quadrupole = tile;
|
|
|
|
//Battery
|
|
this.addSlotToContainer(new Slot(tile, 0, 26, 72));
|
|
//Coil
|
|
this.addSlotToContainer(new Slot(tile, 1, 71, 36));
|
|
|
|
for(int i = 0; i < 3; i++) {
|
|
for(int j = 0; j < 9; j++) {
|
|
this.addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 122 + i * 18));
|
|
}
|
|
}
|
|
|
|
for(int i = 0; i < 9; i++) {
|
|
this.addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 180));
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean canInteractWith(EntityPlayer player) {
|
|
return quadrupole.isUseableByPlayer(player);
|
|
}
|
|
|
|
@Override
|
|
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
|
|
ItemStack rStack = null;
|
|
Slot slot = (Slot) this.inventorySlots.get(index);
|
|
|
|
if(slot != null && slot.getHasStack()) {
|
|
ItemStack stack = slot.getStack();
|
|
rStack = stack.copy();
|
|
|
|
if(index <= 1) {
|
|
if(!this.mergeItemStack(stack, 2, this.inventorySlots.size(), true)) {
|
|
return null;
|
|
}
|
|
} else {
|
|
|
|
if(rStack.getItem() instanceof IBatteryItem || rStack.getItem() == ModItems.battery_creative) {
|
|
if(!this.mergeItemStack(stack, 0, 1, false)) return null;
|
|
} else {
|
|
if(!this.mergeItemStack(stack, 1, 2, false)) return null;
|
|
}
|
|
}
|
|
|
|
if(stack.stackSize == 0) {
|
|
slot.putStack((ItemStack) null);
|
|
} else {
|
|
slot.onSlotChanged();
|
|
}
|
|
}
|
|
|
|
return rStack;
|
|
}
|
|
}
|