mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-28 14:45:59 +00:00
Implemented custom GUIs.
This commit is contained in:
1 parent
d50f51e208
commit
6b9cfb9d25
40 files changed
+3136
-92
No files matched your search
@@ -0,0 +1,298 @@
|
||||
//
|
||||
// Source code recreated from a .class file by IntelliJ IDEA
|
||||
// (powered by FernFlower decompiler)
|
||||
//
|
||||
|
||||
package noppes.npcs.scripted.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||
import noppes.npcs.scripted.interfaces.IPlayer;
|
||||
import noppes.npcs.scripted.interfaces.IButton;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGui;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||
import noppes.npcs.scripted.interfaces.IItemSlot;
|
||||
import noppes.npcs.scripted.interfaces.ILabel;
|
||||
import noppes.npcs.scripted.interfaces.IScroll;
|
||||
import noppes.npcs.scripted.interfaces.ITextField;
|
||||
import noppes.npcs.scripted.interfaces.ITexturedRect;
|
||||
import noppes.npcs.scripted.interfaces.IItemStack;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
import noppes.npcs.controllers.CustomGuiController;
|
||||
import noppes.npcs.controllers.ScriptContainer;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGui;
|
||||
|
||||
public class ScriptGui implements ICustomGui {
|
||||
int id;
|
||||
int width;
|
||||
int height;
|
||||
int playerInvX;
|
||||
int playerInvY;
|
||||
boolean pauseGame;
|
||||
boolean showPlayerInv;
|
||||
String backgroundTexture = "";
|
||||
//ScriptContainer scriptHandler;
|
||||
List<ICustomGuiComponent> components = new ArrayList();
|
||||
List<IItemSlot> slots = new ArrayList();
|
||||
|
||||
public ScriptGui() {
|
||||
}
|
||||
|
||||
public ScriptGui(int id, int width, int height, boolean pauseGame) {
|
||||
this.id = id;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.pauseGame = pauseGame;
|
||||
//this.scriptHandler = ScriptContainer.Current;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public List<ICustomGuiComponent> getComponents() {
|
||||
return this.components;
|
||||
}
|
||||
|
||||
public List<IItemSlot> getSlots() {
|
||||
return this.slots;
|
||||
}
|
||||
|
||||
public PlayerDataScript getScriptHandler() {
|
||||
return ScriptController.Instance.playerScripts;//this.scriptHandler;
|
||||
}
|
||||
|
||||
public void setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public void setDoesPauseGame(boolean pauseGame) {
|
||||
this.pauseGame = pauseGame;
|
||||
}
|
||||
|
||||
public boolean getDoesPauseGame() {
|
||||
return this.pauseGame;
|
||||
}
|
||||
|
||||
public void setBackgroundTexture(String resourceLocation) {
|
||||
this.backgroundTexture = resourceLocation;
|
||||
}
|
||||
|
||||
public String getBackgroundTexture() {
|
||||
return this.backgroundTexture;
|
||||
}
|
||||
|
||||
public IButton addButton(int id, String label, int x, int y) {
|
||||
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y);
|
||||
this.components.add(component);
|
||||
return (IButton)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IButton addButton(int id, String label, int x, int y, int width, int height) {
|
||||
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y, width, height);
|
||||
this.components.add(component);
|
||||
return (IButton)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IButton addTexturedButton(int id, String label, int x, int y, int width, int height, String texture) {
|
||||
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y, width, height, texture);
|
||||
this.components.add(component);
|
||||
return (IButton)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IButton addTexturedButton(int id, String label, int x, int y, int width, int height, String texture, int textureX, int textureY) {
|
||||
ScriptGuiButton component = new ScriptGuiButton(id, label, x, y, width, height, texture, textureX, textureY);
|
||||
this.components.add(component);
|
||||
return (IButton)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public ILabel addLabel(int id, String label, int x, int y, int width, int height) {
|
||||
ScriptGuiLabel component = new ScriptGuiLabel(id, label, x, y, width, height);
|
||||
this.components.add(component);
|
||||
return (ILabel)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public ILabel addLabel(int id, String label, int x, int y, int width, int height, int color) {
|
||||
ScriptGuiLabel component = new ScriptGuiLabel(id, label, x, y, width, height, color);
|
||||
this.components.add(component);
|
||||
return (ILabel)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public ITextField addTextField(int id, int x, int y, int width, int height) {
|
||||
ScriptGuiTextField component = new ScriptGuiTextField(id, x, y, width, height);
|
||||
this.components.add(component);
|
||||
return (ITextField)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public ITexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height) {
|
||||
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(id, texture, x, y, width, height);
|
||||
this.components.add(component);
|
||||
return (ITexturedRect)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public ITexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
ScriptGuiTexturedRect component = new ScriptGuiTexturedRect(id, texture, x, y, width, height, textureX, textureY);
|
||||
this.components.add(component);
|
||||
return (ITexturedRect)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IItemSlot addItemSlot(int x, int y) {
|
||||
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(x, y);
|
||||
this.slots.add(slot);
|
||||
return (IItemSlot)this.slots.get(this.slots.size() - 1);
|
||||
}
|
||||
|
||||
public IItemSlot addItemSlot(int x, int y, IItemStack stack) {
|
||||
ScriptGuiItemSlot slot = new ScriptGuiItemSlot(x, y, stack);
|
||||
this.slots.add(slot);
|
||||
return (IItemSlot)this.slots.get(this.slots.size() - 1);
|
||||
}
|
||||
|
||||
public IScroll addScroll(int id, int x, int y, int width, int height, String[] list) {
|
||||
ScriptGuiScroll component = new ScriptGuiScroll(id, x, y, width, height, list);
|
||||
this.components.add(component);
|
||||
return (IScroll)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public void showPlayerInventory(int x, int y) {
|
||||
this.showPlayerInv = true;
|
||||
this.playerInvX = x;
|
||||
this.playerInvY = y;
|
||||
}
|
||||
|
||||
public ICustomGuiComponent getComponent(int componentID) {
|
||||
Iterator var2 = this.components.iterator();
|
||||
|
||||
ICustomGuiComponent component;
|
||||
do {
|
||||
if (!var2.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
component = (ICustomGuiComponent)var2.next();
|
||||
} while(component.getID() != componentID);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public void removeComponent(int componentID) {
|
||||
for(int i = 0; i < this.components.size(); ++i) {
|
||||
if (((ICustomGuiComponent)this.components.get(i)).getID() == componentID) {
|
||||
this.components.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateComponent(ICustomGuiComponent component) {
|
||||
for(int i = 0; i < this.components.size(); ++i) {
|
||||
ICustomGuiComponent c = (ICustomGuiComponent)this.components.get(i);
|
||||
if (c.getID() == component.getID()) {
|
||||
this.components.set(i, component);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void update(IPlayer player) {
|
||||
CustomGuiController.updateGui((ScriptPlayer)player, this);
|
||||
}
|
||||
|
||||
public boolean getShowPlayerInv() {
|
||||
return this.showPlayerInv;
|
||||
}
|
||||
|
||||
public int getPlayerInvX() {
|
||||
return this.playerInvX;
|
||||
}
|
||||
|
||||
public int getPlayerInvY() {
|
||||
return this.playerInvY;
|
||||
}
|
||||
|
||||
public ICustomGui fromNBT(NBTTagCompound tag) {
|
||||
this.id = tag.getInteger("id");
|
||||
this.width = tag.getIntArray("size")[0];
|
||||
this.height = tag.getIntArray("size")[1];
|
||||
this.pauseGame = tag.getBoolean("pause");
|
||||
this.backgroundTexture = tag.getString("bgTexture");
|
||||
List<ICustomGuiComponent> components = new ArrayList();
|
||||
|
||||
NBTTagList list = tag.getTagList("components", 10);
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
NBTBase b = list.getCompoundTagAt(i);
|
||||
ScriptGuiComponent component = ScriptGuiComponent.createFromNBT((NBTTagCompound)b);
|
||||
components.add(component);
|
||||
}
|
||||
|
||||
this.components = components;
|
||||
List<IItemSlot> slots = new ArrayList();
|
||||
list = tag.getTagList("slots", 10);
|
||||
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
NBTBase b = list.getCompoundTagAt(i);
|
||||
ScriptGuiItemSlot component = (ScriptGuiItemSlot)ScriptGuiComponent.createFromNBT((NBTTagCompound)b);
|
||||
slots.add(component);
|
||||
}
|
||||
|
||||
this.slots = slots;
|
||||
this.showPlayerInv = tag.getBoolean("showPlayerInv");
|
||||
if (this.showPlayerInv) {
|
||||
this.playerInvX = tag.getIntArray("pInvPos")[0];
|
||||
this.playerInvY = tag.getIntArray("pInvPos")[1];
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("id", this.id);
|
||||
tag.setIntArray("size", new int[]{this.width, this.height});
|
||||
tag.setBoolean("pause", this.pauseGame);
|
||||
tag.setString("bgTexture", this.backgroundTexture);
|
||||
NBTTagList list = new NBTTagList();
|
||||
Iterator var3 = this.components.iterator();
|
||||
|
||||
ICustomGuiComponent c;
|
||||
while(var3.hasNext()) {
|
||||
c = (ICustomGuiComponent)var3.next();
|
||||
list.appendTag(((ScriptGuiComponent)c).toNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
tag.setTag("components", list);
|
||||
list = new NBTTagList();
|
||||
var3 = this.slots.iterator();
|
||||
|
||||
while(var3.hasNext()) {
|
||||
c = (ICustomGuiComponent)var3.next();
|
||||
list.appendTag(((ScriptGuiComponent)c).toNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
tag.setTag("slots", list);
|
||||
tag.setBoolean("showPlayerInv", this.showPlayerInv);
|
||||
if (this.showPlayerInv) {
|
||||
tag.setIntArray("pInvPos", new int[]{this.playerInvX, this.playerInvY});
|
||||
}
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package noppes.npcs.scripted.gui;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.interfaces.IButton;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||
|
||||
public class ScriptGuiButton extends ScriptGuiComponent implements IButton {
|
||||
int width;
|
||||
int height;
|
||||
String label;
|
||||
String texture;
|
||||
int textureX;
|
||||
int textureY;
|
||||
|
||||
public ScriptGuiButton() {
|
||||
this.height = -1;
|
||||
this.textureY = -1;
|
||||
}
|
||||
|
||||
public ScriptGuiButton(int id, String label, int x, int y) {
|
||||
this.height = -1;
|
||||
this.textureY = -1;
|
||||
this.setID(id);
|
||||
this.setLabel(label);
|
||||
this.setPos(x, y);
|
||||
}
|
||||
|
||||
public ScriptGuiButton(int id, String label, int x, int y, int width, int height) {
|
||||
this(id, label, x, y);
|
||||
this.setSize(width, height);
|
||||
}
|
||||
|
||||
public ScriptGuiButton(int id, String label, int x, int y, int width, int height, String texture) {
|
||||
this(id, label, x, y, width, height);
|
||||
this.setTexture(texture);
|
||||
}
|
||||
|
||||
public ScriptGuiButton(int id, String label, int x, int y, int width, int height, String texture, int textureX, int textureY) {
|
||||
this(id, label, x, y, width, height, texture);
|
||||
this.setTextureOffset(textureX, textureY);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public IButton setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public IButton setLabel(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
public boolean hasTexture() {
|
||||
return this.texture != null;
|
||||
}
|
||||
|
||||
public IButton setTexture(String texture) {
|
||||
this.texture = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTextureX() {
|
||||
return this.textureX;
|
||||
}
|
||||
|
||||
public int getTextureY() {
|
||||
return this.textureY;
|
||||
}
|
||||
|
||||
public IButton setTextureOffset(int textureX, int textureY) {
|
||||
this.textureX = textureX;
|
||||
this.textureY = textureY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public ICustomGuiComponent setID(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPosX() {
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
public int getPosY() {
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
super.toNBT(nbt);
|
||||
if (this.width > 0 && this.height > 0) {
|
||||
nbt.setIntArray("size", new int[]{this.width, this.height});
|
||||
}
|
||||
|
||||
nbt.setString("label", this.label);
|
||||
if (this.hasTexture()) {
|
||||
nbt.setString("texture", this.texture);
|
||||
}
|
||||
|
||||
if (this.textureX >= 0 && this.textureY >= 0) {
|
||||
nbt.setIntArray("texPos", new int[]{this.textureX, this.textureY});
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
|
||||
super.fromNBT(nbt);
|
||||
if (nbt.hasKey("size")) {
|
||||
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
|
||||
}
|
||||
|
||||
this.setLabel(nbt.getString("label"));
|
||||
if (nbt.hasKey("texture")) {
|
||||
this.setTexture(nbt.getString("texture"));
|
||||
}
|
||||
|
||||
if (nbt.hasKey("texPos")) {
|
||||
this.setTextureOffset(nbt.getIntArray("texPos")[0], nbt.getIntArray("texPos")[1]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
package noppes.npcs.scripted.gui;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||
|
||||
public abstract class ScriptGuiComponent implements ICustomGuiComponent {
|
||||
int id;
|
||||
int posX;
|
||||
int posY;
|
||||
String[] hoverText;
|
||||
|
||||
public ScriptGuiComponent() {
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public ICustomGuiComponent setID(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPosX() {
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
public int getPosY() {
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
public ICustomGuiComponent setPos(int x, int y) {
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasHoverText() {
|
||||
return this.hoverText != null && this.hoverText.length > 0;
|
||||
}
|
||||
|
||||
public String[] getHoverText() {
|
||||
return this.hoverText;
|
||||
}
|
||||
|
||||
public ICustomGuiComponent setHoverText(String text) {
|
||||
this.hoverText = new String[]{text};
|
||||
return this;
|
||||
}
|
||||
|
||||
public ICustomGuiComponent setHoverText(String[] text) {
|
||||
this.hoverText = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
public abstract int getType();
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("id", this.id);
|
||||
nbt.setIntArray("pos", new int[]{this.posX, this.posY});
|
||||
if (this.hoverText != null) {
|
||||
NBTTagList list = new NBTTagList();
|
||||
String[] var3 = this.hoverText;
|
||||
int var4 = var3.length;
|
||||
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
String s = var3[var5];
|
||||
if (s != null && !s.isEmpty()) {
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
}
|
||||
|
||||
if (list.tagCount() > 0) {
|
||||
nbt.setTag("hover", list);
|
||||
}
|
||||
}
|
||||
|
||||
nbt.setInteger("type", this.getType());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
|
||||
this.setID(nbt.getInteger("id"));
|
||||
this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]);
|
||||
if (nbt.hasKey("hover")) {
|
||||
NBTTagList list = nbt.getTagList("hover", 8);
|
||||
String[] hoverText = new String[list.tagCount()];
|
||||
|
||||
for(int i = 0; i < list.tagCount(); ++i) {
|
||||
hoverText[i] = list.getStringTagAt(i);
|
||||
}
|
||||
|
||||
this.setHoverText(hoverText);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public static ScriptGuiComponent createFromNBT(NBTTagCompound nbt) {
|
||||
switch(nbt.getInteger("type")) {
|
||||
case 0:
|
||||
return (new ScriptGuiButton()).fromNBT(nbt);
|
||||
case 1:
|
||||
return (new ScriptGuiLabel()).fromNBT(nbt);
|
||||
case 2:
|
||||
return (new ScriptGuiTexturedRect()).fromNBT(nbt);
|
||||
case 3:
|
||||
return (new ScriptGuiTextField()).fromNBT(nbt);
|
||||
case 4:
|
||||
return (new ScriptGuiScroll()).fromNBT(nbt);
|
||||
case 5:
|
||||
return (new ScriptGuiItemSlot()).fromNBT(nbt);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package noppes.npcs.scripted.gui;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.interfaces.ILabel;
|
||||
|
||||
public class ScriptGuiLabel extends ScriptGuiComponent implements ILabel {
|
||||
String label;
|
||||
int width;
|
||||
int height;
|
||||
int color;
|
||||
float scale;
|
||||
|
||||
public ScriptGuiLabel() {
|
||||
this.color = 16777215;
|
||||
this.scale = 1.0F;
|
||||
}
|
||||
|
||||
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height) {
|
||||
this.color = 16777215;
|
||||
this.scale = 1.0F;
|
||||
this.setID(id);
|
||||
this.setText(label);
|
||||
this.setPos(x, y);
|
||||
this.setSize(width, height);
|
||||
}
|
||||
|
||||
public ScriptGuiLabel(int id, String label, int x, int y, int width, int height, int color) {
|
||||
this(id, label, x, y, width, height);
|
||||
this.setColor(color);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public ILabel setText(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public ILabel setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public ILabel setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
public ILabel setScale(float scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
super.toNBT(nbt);
|
||||
nbt.setString("label", this.label);
|
||||
nbt.setIntArray("size", new int[]{this.width, this.height});
|
||||
nbt.setInteger("color", this.color);
|
||||
nbt.setFloat("scale", this.scale);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
|
||||
super.fromNBT(nbt);
|
||||
this.setText(nbt.getString("label"));
|
||||
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
|
||||
this.setColor(nbt.getInteger("color"));
|
||||
this.setScale(nbt.getFloat("scale"));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package noppes.npcs.scripted.gui;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.scripted.interfaces.IScroll;
|
||||
|
||||
public class ScriptGuiScroll extends ScriptGuiComponent implements IScroll {
|
||||
int width;
|
||||
int height;
|
||||
int defaultSelection = -1;
|
||||
String[] list;
|
||||
boolean multiSelect = false;
|
||||
|
||||
public ScriptGuiScroll() {
|
||||
}
|
||||
|
||||
public ScriptGuiScroll(int id, int x, int y, int width, int height, String[] list) {
|
||||
this.setID(id);
|
||||
this.setPos(x, y);
|
||||
this.setSize(width, height);
|
||||
this.setList(list);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public IScroll setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String[] getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public IScroll setList(String[] list) {
|
||||
this.list = list;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getDefaultSelection() {
|
||||
return this.defaultSelection;
|
||||
}
|
||||
|
||||
public IScroll setDefaultSelection(int defaultSelection) {
|
||||
this.defaultSelection = defaultSelection;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isMultiSelect() {
|
||||
return this.multiSelect;
|
||||
}
|
||||
|
||||
public IScroll setMultiSelect(boolean multiSelect) {
|
||||
this.multiSelect = multiSelect;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
super.toNBT(nbt);
|
||||
nbt.setIntArray("size", new int[]{this.width, this.height});
|
||||
if (this.defaultSelection >= 0) {
|
||||
nbt.setInteger("default", this.defaultSelection);
|
||||
}
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
String[] var3 = this.list;
|
||||
int var4 = var3.length;
|
||||
|
||||
for(int var5 = 0; var5 < var4; ++var5) {
|
||||
String s = var3[var5];
|
||||
list.appendTag(new NBTTagString(s));
|
||||
}
|
||||
|
||||
nbt.setTag("list", list);
|
||||
nbt.setBoolean("multiSelect", this.multiSelect);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
|
||||
super.fromNBT(nbt);
|
||||
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
|
||||
if (nbt.hasKey("default")) {
|
||||
this.setDefaultSelection(nbt.getInteger("default"));
|
||||
}
|
||||
|
||||
NBTTagList tagList = nbt.getTagList("list", 8);
|
||||
String[] list = new String[tagList.tagCount()];
|
||||
|
||||
for(int i = 0; i < tagList.tagCount(); ++i) {
|
||||
list[i] = tagList.getStringTagAt(i);
|
||||
}
|
||||
|
||||
this.setList(list);
|
||||
this.setMultiSelect(nbt.getBoolean("multiSelect"));
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package noppes.npcs.scripted.gui;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.interfaces.ITextField;
|
||||
|
||||
public class ScriptGuiTextField extends ScriptGuiComponent implements ITextField {
|
||||
int width;
|
||||
int height;
|
||||
String defaultText;
|
||||
|
||||
public ScriptGuiTextField() {
|
||||
}
|
||||
|
||||
public ScriptGuiTextField(int id, int x, int y, int width, int height) {
|
||||
this.setID(id);
|
||||
this.setPos(x, y);
|
||||
this.setSize(width, height);
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public ITextField setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return this.defaultText;
|
||||
}
|
||||
|
||||
public ITextField setText(String defaultText) {
|
||||
this.defaultText = defaultText;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
super.toNBT(nbt);
|
||||
nbt.setIntArray("size", new int[]{this.width, this.height});
|
||||
if (this.defaultText != null && !this.defaultText.isEmpty()) {
|
||||
nbt.setString("default", this.defaultText);
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
|
||||
super.fromNBT(nbt);
|
||||
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
|
||||
if (nbt.hasKey("default")) {
|
||||
this.setText(nbt.getString("default"));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package noppes.npcs.scripted.gui;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.client.gui.custom.GuiCustom;
|
||||
import noppes.npcs.scripted.interfaces.ITexturedRect;
|
||||
|
||||
public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITexturedRect {
|
||||
int width;
|
||||
int height;
|
||||
int textureX;
|
||||
int textureY;
|
||||
float scale;
|
||||
String texture;
|
||||
|
||||
public ScriptGuiTexturedRect() {
|
||||
this.textureY = -1;
|
||||
this.scale = 1.0F;
|
||||
}
|
||||
|
||||
public ScriptGuiTexturedRect(int id, String texture, int x, int y, int width, int height) {
|
||||
this.textureY = -1;
|
||||
this.scale = 1.0F;
|
||||
this.setID(id);
|
||||
this.setTexture(texture);
|
||||
this.setPos(GuiCustom.guiLeft + x, GuiCustom.guiTop + y);
|
||||
this.setSize(width, height);
|
||||
}
|
||||
|
||||
public ScriptGuiTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
this(id, texture, GuiCustom.guiLeft + x, GuiCustom.guiTop + y, width, height);
|
||||
this.setTextureOffset(textureX, textureY);
|
||||
}
|
||||
|
||||
public String getTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
public ITexturedRect setTexture(String texture) {
|
||||
this.texture = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public ITexturedRect setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
public ITexturedRect setScale(float scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTextureX() {
|
||||
return this.textureX;
|
||||
}
|
||||
|
||||
public int getTextureY() {
|
||||
return this.textureY;
|
||||
}
|
||||
|
||||
public ITexturedRect setTextureOffset(int offsetX, int offsetY) {
|
||||
this.textureX = offsetX;
|
||||
this.textureY = offsetY;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
super.toNBT(nbt);
|
||||
nbt.setIntArray("size", new int[]{this.width, this.height});
|
||||
nbt.setFloat("scale", this.scale);
|
||||
nbt.setString("texture", this.texture);
|
||||
if (this.textureX >= 0 && this.textureY >= 0) {
|
||||
nbt.setIntArray("texPos", new int[]{this.textureX, this.textureY});
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptGuiComponent fromNBT(NBTTagCompound nbt) {
|
||||
super.fromNBT(nbt);
|
||||
this.setSize(nbt.getIntArray("size")[0], nbt.getIntArray("size")[1]);
|
||||
this.setScale(nbt.getFloat("scale"));
|
||||
this.setTexture(nbt.getString("texture"));
|
||||
if (nbt.hasKey("texPos")) {
|
||||
this.setTextureOffset(nbt.getIntArray("texPos")[0], nbt.getIntArray("texPos")[1]);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user