Files
CustomNPC-Plus/src/main/java/noppes/npcs/scripted/gui/ScriptGuiItemSlot.java
T

63 lines
1.5 KiB
Java
Raw Normal View History

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;
import noppes.npcs.scripted.interfaces.gui.IItemSlot;
import noppes.npcs.scripted.interfaces.item.IItemStack;
import noppes.npcs.scripted.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;
}
}