2022-01-12 04:44:08 -06:00
|
|
|
package noppes.npcs.scripted.gui;
|
|
|
|
|
|
|
|
|
|
import net.minecraft.inventory.Slot;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2022-05-11 16:43:14 -05:00
|
|
|
import noppes.npcs.scripted.interfaces.gui.IItemSlot;
|
|
|
|
|
import noppes.npcs.scripted.interfaces.item.IItemStack;
|
2022-05-11 17:12:48 -05:00
|
|
|
import noppes.npcs.scripted.wrapper.NpcAPI;
|
2022-01-12 04:44:08 -06:00
|
|
|
|
|
|
|
|
public class ScriptGuiItemSlot extends ScriptGuiComponent implements IItemSlot {
|
|
|
|
|
IItemStack stack;
|
|
|
|
|
|
|
|
|
|
public ScriptGuiItemSlot() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScriptGuiItemSlot(int x, int y) {
|
|
|
|
|
this.setPos(x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScriptGuiItemSlot(int x, int y, IItemStack stack) {
|
|
|
|
|
this(x, y);
|
|
|
|
|
this.setStack(stack);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasStack() {
|
|
|
|
|
return this.stack != null && this.stack.getStackSize() > 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IItemStack getStack() {
|
|
|
|
|
return this.stack;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IItemSlot setStack(IItemStack itemStack) {
|
|
|
|
|
this.stack = itemStack;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Slot getMCSlot() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getType() {
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
|
|
|
|
super.toNBT(nbt);
|
|
|
|
|
if (this.hasStack()) {
|
|
|
|
|
nbt.setTag("stack", this.stack.getItemNbt().getMCNBT());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nbt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
|
|
|
|
|
super.fromNBT(nbt);
|
|
|
|
|
if (nbt.hasKey("stack")) {
|
|
|
|
|
this.setStack(NpcAPI.Instance().getIItemStack(ItemStack.loadItemStackFromNBT(nbt.getCompoundTag("stack"))));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
}
|