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

@@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.stats.Achievement;
import net.minecraft.stats.StatBase;
import net.minecraft.stats.StatList;
@@ -16,20 +17,17 @@ import noppes.npcs.NoppesUtilPlayer;
import noppes.npcs.Server;
import noppes.npcs.constants.EnumPacketClient;
import noppes.npcs.constants.EnumQuestType;
import noppes.npcs.controllers.PixelmonHelper;
import noppes.npcs.controllers.PlayerData;
import noppes.npcs.controllers.PlayerDataController;
import noppes.npcs.controllers.PlayerDialogData;
import noppes.npcs.controllers.PlayerQuestData;
import noppes.npcs.controllers.Quest;
import noppes.npcs.controllers.QuestController;
import noppes.npcs.controllers.QuestData;
import noppes.npcs.containers.ContainerCustomGui;
import noppes.npcs.controllers.*;
import noppes.npcs.scripted.CustomNPCsException;
import noppes.npcs.scripted.NpcAPI;
import noppes.npcs.scripted.ScriptItemStack;
import noppes.npcs.scripted.ScriptPixelmonPlayerData;
import noppes.npcs.scripted.constants.EntityType;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.handler.data.IQuest;
import noppes.npcs.scripted.interfaces.IContainer;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.IPlayer;
import noppes.npcs.scripted.interfaces.ITimers;
import noppes.npcs.util.ValueUtil;
@@ -440,6 +438,23 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
return (IQuest[])quests.toArray(new IQuest[quests.size()]);
}
public IContainer getOpenContainer() {
return NpcAPI.Instance().getIContainer(((EntityPlayerMP)this.entity).openContainer);
}
public void showCustomGui(ICustomGui gui) {
CustomGuiController.openGui(this, (ScriptGui) gui);
}
public ICustomGui getCustomGui() {
return ((EntityPlayerMP)this.entity).openContainer instanceof ContainerCustomGui ? ((ContainerCustomGui)((EntityPlayerMP)this.entity).openContainer).customGui : null;
}
public void closeGui() {
((EntityPlayerMP)this.entity).closeContainer();
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.GUI_CLOSE, new Object[]{-1, new NBTTagCompound()});
}
public IQuest[] getFinishedQuests() {
PlayerQuestData data = this.getData().questData;
List<IQuest> quests = new ArrayList();
@@ -0,0 +1,57 @@
package noppes.npcs.scripted.event;
import cpw.mods.fml.common.eventhandler.Event;
import noppes.npcs.scripted.interfaces.ICustomGui;
import noppes.npcs.scripted.interfaces.IItemStack;
import noppes.npcs.scripted.interfaces.IPlayer;
public class CustomGuiEvent extends Event {
public final IPlayer player;
public final ICustomGui gui;
public CustomGuiEvent(IPlayer player, ICustomGui gui) {
this.player = player;
this.gui = gui;
}
public static class ButtonEvent extends CustomGuiEvent {
public final int buttonId;
public ButtonEvent(IPlayer player, ICustomGui gui, int buttonId) {
super(player, gui);
this.buttonId = buttonId;
}
}
public static class CloseEvent extends CustomGuiEvent {
public CloseEvent(IPlayer player, ICustomGui gui) {
super(player, gui);
}
}
public static class ScrollEvent extends CustomGuiEvent {
public final int scrollId;
public final String[] selection;
public final boolean doubleClick;
public final int scrollIndex;
public ScrollEvent(IPlayer player, ICustomGui gui, int scrollId, int scrollIndex, String[] selection, boolean doubleClick) {
super(player, gui);
this.scrollId = scrollId;
this.selection = selection;
this.doubleClick = doubleClick;
this.scrollIndex = scrollIndex;
}
}
public static class SlotEvent extends CustomGuiEvent {
public final int slotId;
public final IItemStack stack;
public SlotEvent(IPlayer player, ICustomGui gui, int slotId, IItemStack stack) {
super(player, gui);
this.slotId = slotId;
this.stack = stack;
}
}
}
@@ -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;
}
}
@@ -0,0 +1,30 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
public interface IButton extends ICustomGuiComponent {
int getWidth();
int getHeight();
IButton setSize(int var1, int var2);
String getLabel();
IButton setLabel(String var1);
String getTexture();
boolean hasTexture();
IButton setTexture(String var1);
int getTextureX();
int getTextureY();
IButton setTextureOffset(int var1, int var2);
}
@@ -0,0 +1,60 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
import java.util.List;
public interface ICustomGui {
int getID();
int getWidth();
int getHeight();
List<ICustomGuiComponent> getComponents();
List<IItemSlot> getSlots();
void setSize(int var1, int var2);
void setDoesPauseGame(boolean var1);
void setBackgroundTexture(String var1);
IButton addButton(int var1, String var2, int var3, int var4);
IButton addButton(int var1, String var2, int var3, int var4, int var5, int var6);
IButton addTexturedButton(int var1, String var2, int var3, int var4, int var5, int var6, String var7);
IButton addTexturedButton(int var1, String var2, int var3, int var4, int var5, int var6, String var7, int var8, int var9);
ILabel addLabel(int var1, String var2, int var3, int var4, int var5, int var6);
ILabel addLabel(int var1, String var2, int var3, int var4, int var5, int var6, int var7);
ITextField addTextField(int var1, int var2, int var3, int var4, int var5);
ITexturedRect addTexturedRect(int var1, String var2, int var3, int var4, int var5, int var6);
ITexturedRect addTexturedRect(int var1, String var2, int var3, int var4, int var5, int var6, int var7, int var8);
IScroll addScroll(int var1, int var2, int var3, int var4, int var5, String[] var6);
IItemSlot addItemSlot(int var1, int var2);
IItemSlot addItemSlot(int var1, int var2, IItemStack var3);
void showPlayerInventory(int var1, int var2);
ICustomGuiComponent getComponent(int var1);
void removeComponent(int var1);
void updateComponent(ICustomGuiComponent var1);
void update(IPlayer var1);
}
@@ -0,0 +1,26 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
public interface ICustomGuiComponent {
int getID();
ICustomGuiComponent setID(int var1);
int getPosX();
int getPosY();
ICustomGuiComponent setPos(int var1, int var2);
boolean hasHoverText();
String[] getHoverText();
ICustomGuiComponent setHoverText(String var1);
ICustomGuiComponent setHoverText(String[] var1);
}
@@ -0,0 +1,18 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
import net.minecraft.inventory.Slot;
public interface IItemSlot extends ICustomGuiComponent {
boolean hasStack();
IItemStack getStack();
IItemSlot setStack(IItemStack var1);
Slot getMCSlot();
}
@@ -0,0 +1,26 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
public interface ILabel extends ICustomGuiComponent {
String getText();
ILabel setText(String var1);
int getWidth();
int getHeight();
ILabel setSize(int var1, int var2);
int getColor();
ILabel setColor(int var1);
float getScale();
ILabel setScale(float var1);
}
@@ -0,0 +1,26 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
public interface IScroll extends ICustomGuiComponent {
int getWidth();
int getHeight();
IScroll setSize(int var1, int var2);
String[] getList();
IScroll setList(String[] var1);
int getDefaultSelection();
IScroll setDefaultSelection(int var1);
boolean isMultiSelect();
IScroll setMultiSelect(boolean var1);
}
@@ -0,0 +1,18 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
public interface ITextField extends ICustomGuiComponent {
int getWidth();
int getHeight();
ITextField setSize(int var1, int var2);
String getText();
ITextField setText(String var1);
}
@@ -0,0 +1,28 @@
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package noppes.npcs.scripted.interfaces;
public interface ITexturedRect extends ICustomGuiComponent {
String getTexture();
ITexturedRect setTexture(String var1);
int getWidth();
int getHeight();
ITexturedRect setSize(int var1, int var2);
float getScale();
ITexturedRect setScale(float var1);
int getTextureX();
int getTextureY();
ITexturedRect setTextureOffset(int var1, int var2);
}
@@ -8,9 +8,7 @@ package noppes.npcs.scripted.wrapper;
import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.eventhandler.EventBus;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
@@ -31,10 +29,8 @@ import net.minecraft.util.EntityDamageSource;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayer;
import noppes.npcs.CustomNpcs;
import noppes.npcs.NoppesUtilServer;
import noppes.npcs.client.EntityUtil;
import noppes.npcs.controllers.*;
import noppes.npcs.scripted.*;
import noppes.npcs.containers.ContainerNpcInterface;
@@ -42,6 +38,7 @@ import noppes.npcs.entity.EntityCustomNpc;
import noppes.npcs.entity.EntityNPCInterface;
import noppes.npcs.scripted.ScriptContainer;
import noppes.npcs.scripted.entity.*;
import noppes.npcs.scripted.gui.ScriptGui;
import noppes.npcs.scripted.handler.*;
import noppes.npcs.scripted.interfaces.*;
import noppes.npcs.util.JsonException;
@@ -271,4 +268,8 @@ public class WrapperNpcAPI extends NpcAPI {
public int getServerTime() {
return MinecraftServer.getServer().getTickCounter();
}
public ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame) {
return new ScriptGui(id, width, height, pauseGame);
}
}