2022-01-06 01:24:28 -08:00
|
|
|
package tconstruct.tools.gui;
|
|
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2022-05-14 10:22:11 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2022-01-06 01:24:28 -08:00
|
|
|
import net.minecraft.inventory.IInventory;
|
2022-05-14 10:22:11 +01:00
|
|
|
import net.minecraft.inventory.ISidedInventory;
|
2022-01-06 01:24:28 -08:00
|
|
|
import net.minecraft.inventory.Slot;
|
2022-05-14 10:22:11 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2022-01-06 01:24:28 -08:00
|
|
|
|
|
|
|
|
public class ChestSlot extends Slot {
|
|
|
|
|
/*
|
|
|
|
|
* A Slot, used for adjacent Chest Inventories, that can be disabled.
|
|
|
|
|
*/
|
|
|
|
|
public boolean enabled = true;
|
2022-05-14 10:22:11 +01:00
|
|
|
private int accessSide;
|
|
|
|
|
private int visualIndex;
|
|
|
|
|
|
|
|
|
|
public ChestSlot(IInventory inventory, int index, int visualIndex, int xPosition, int yPosition, int accessSide) {
|
2022-01-06 01:24:28 -08:00
|
|
|
super(inventory, index, xPosition, yPosition);
|
2022-05-14 10:22:11 +01:00
|
|
|
this.accessSide = accessSide;
|
|
|
|
|
this.visualIndex = visualIndex;
|
2022-01-06 01:24:28 -08:00
|
|
|
}
|
2022-05-14 10:22:11 +01:00
|
|
|
|
2022-01-06 01:24:28 -08:00
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
@Override
|
|
|
|
|
public boolean func_111238_b/*isEnabled*/() {
|
|
|
|
|
return enabled;
|
|
|
|
|
}
|
2022-05-14 10:22:11 +01:00
|
|
|
|
|
|
|
|
public int getVisualIndex() {
|
|
|
|
|
return visualIndex;
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-06 01:24:28 -08:00
|
|
|
public void disable() {
|
|
|
|
|
enabled = false;
|
|
|
|
|
}
|
2022-05-14 10:22:11 +01:00
|
|
|
|
2022-01-06 01:24:28 -08:00
|
|
|
public void enable() {
|
|
|
|
|
enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-14 10:22:11 +01:00
|
|
|
@Override
|
|
|
|
|
public boolean isItemValid(ItemStack itemStack) {
|
|
|
|
|
if (inventory instanceof ISidedInventory) {
|
|
|
|
|
ISidedInventory sided = (ISidedInventory) inventory;
|
|
|
|
|
return sided.canInsertItem(this.getSlotIndex(), itemStack, accessSide);
|
|
|
|
|
}
|
|
|
|
|
return inventory.isItemValidForSlot(this.getSlotIndex(), itemStack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean canTakeStack(EntityPlayer player) {
|
|
|
|
|
if (inventory instanceof ISidedInventory) {
|
|
|
|
|
ISidedInventory sided = (ISidedInventory) inventory;
|
|
|
|
|
return sided.canExtractItem(this.getSlotIndex(), this.getStack(), accessSide);
|
|
|
|
|
}
|
|
|
|
|
return super.canTakeStack(player);
|
|
|
|
|
}
|
2022-01-06 01:24:28 -08:00
|
|
|
}
|