2022-11-20 20:46:22 +01:00
|
|
|
package dev.tilera.auracore.container;
|
|
|
|
|
|
|
|
import dev.tilera.auracore.api.IWand;
|
2023-01-20 18:43:51 +01:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2022-11-20 20:46:22 +01:00
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2023-01-20 18:43:51 +01:00
|
|
|
import thaumcraft.common.Thaumcraft;
|
2022-11-20 20:46:22 +01:00
|
|
|
import thaumcraft.common.items.wands.ItemWandCasting;
|
2023-01-20 18:43:51 +01:00
|
|
|
import thaumcraft.common.tiles.TileArcaneWorkbench;
|
2022-11-20 20:46:22 +01:00
|
|
|
|
|
|
|
class SlotWorkbenchWand extends Slot {
|
2023-01-20 18:43:51 +01:00
|
|
|
TileArcaneWorkbench workbench;
|
|
|
|
EntityPlayer player;
|
|
|
|
|
|
|
|
public SlotWorkbenchWand(TileArcaneWorkbench par2IInventory, int par3, int par4, int par5, EntityPlayer player) {
|
2022-11-20 20:46:22 +01:00
|
|
|
super(par2IInventory, par3, par4, par5);
|
2023-01-20 18:43:51 +01:00
|
|
|
this.workbench = par2IInventory;
|
|
|
|
this.player = player;
|
2022-11-20 20:46:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isItemValid(ItemStack par1ItemStack) {
|
|
|
|
return par1ItemStack.getItem() instanceof ItemWandCasting || par1ItemStack.getItem() instanceof IWand;
|
|
|
|
}
|
2023-01-20 18:43:51 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSlotChanged() {
|
|
|
|
super.onSlotChanged();
|
|
|
|
if (
|
|
|
|
!this.workbench.getWorldObj().isRemote &&
|
|
|
|
this.inventory.getStackInSlot(this.getSlotIndex()) != null &&
|
|
|
|
this.inventory.getStackInSlot(this.getSlotIndex()).getItem() instanceof ItemWandCasting) {
|
2023-05-20 21:29:13 +02:00
|
|
|
player.inventory.setItemStack(null);
|
2023-01-20 18:43:51 +01:00
|
|
|
player.openGui(Thaumcraft.instance, 13, this.workbench.getWorldObj(), this.workbench.xCoord, this.workbench.yCoord, this.workbench.zCoord);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-20 20:46:22 +01:00
|
|
|
}
|