Implemented custom GUIs.

This commit is contained in:
luisc committed 2022-01-12 04:44:08 -06:00
1 parent d50f51e208
commit 6b9cfb9d25
40 files changed
+3136 -92

No files matched your search

@@ -0,0 +1,63 @@
package noppes.npcs.scripted.gui;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.interfaces.IItemSlot;
import noppes.npcs.scripted.interfaces.IItemStack;
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;
}
}