mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-21 18:32:17 +00:00
Implemented Scripted Overlays which stay on the player's screen. Overlays persist in the client, and can be removed from the screen as well.
This commit is contained in:
1 parent
8b24dad211
commit
534f716991
25 files changed
+1105
-19
No files matched your search
@@ -25,10 +25,8 @@ import noppes.npcs.scripted.constants.EntityType;
|
||||
import noppes.npcs.scripted.event.FactionEvent;
|
||||
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.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlay;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -459,7 +457,15 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
|
||||
public void closeGui() {
|
||||
((EntityPlayerMP)this.entity).closeContainer();
|
||||
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.GUI_CLOSE, new Object[]{-1, new NBTTagCompound()});
|
||||
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.GUI_CLOSE, -1, new NBTTagCompound());
|
||||
}
|
||||
|
||||
public void showCustomOverlay(ICustomOverlay overlay) {
|
||||
CustomGuiController.openOverlay(this, (ScriptOverlay) overlay);
|
||||
}
|
||||
|
||||
public void closeOverlay(int id) {
|
||||
Server.sendData((EntityPlayerMP)this.entity, EnumPacketClient.OVERLAY_CLOSE, id, new NBTTagCompound());
|
||||
}
|
||||
|
||||
public IQuest[] getFinishedQuests() {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
public interface ICustomOverlay {
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
public interface ICustomOverlayComponent {
|
||||
int getID();
|
||||
|
||||
ICustomOverlayComponent setID(int id);
|
||||
|
||||
int getPosX();
|
||||
|
||||
int getPosY();
|
||||
|
||||
ICustomOverlayComponent setPos(int x, int y);
|
||||
|
||||
int getAlignment();
|
||||
|
||||
void setAlignment(int alignment);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
public interface IOverlayLabel extends ICustomOverlayComponent {
|
||||
String getText();
|
||||
|
||||
IOverlayLabel setText(String var1);
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
IOverlayLabel setSize(int var1, int var2);
|
||||
|
||||
int getColor();
|
||||
|
||||
IOverlayLabel setColor(int var1);
|
||||
|
||||
float getScale();
|
||||
|
||||
IOverlayLabel setScale(float var1);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
public interface IOverlayLine extends ICustomOverlayComponent {
|
||||
int getX1();
|
||||
int getY1();
|
||||
int getX2();
|
||||
int getY2();
|
||||
int getColor();
|
||||
int getThickness();
|
||||
|
||||
void setX1(int x1);
|
||||
void setY1(int y1);
|
||||
void setX2(int x2);
|
||||
void setY2(int y2);
|
||||
void setColor(int color);
|
||||
void setThickness(int thickness);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package noppes.npcs.scripted.interfaces;
|
||||
|
||||
public interface IOverlayTexturedRect extends ICustomOverlayComponent {
|
||||
String getTexture();
|
||||
|
||||
IOverlayTexturedRect setTexture(String var1);
|
||||
|
||||
int getWidth();
|
||||
|
||||
int getHeight();
|
||||
|
||||
IOverlayTexturedRect setSize(int var1, int var2);
|
||||
|
||||
float getScale();
|
||||
|
||||
IOverlayTexturedRect setScale(float var1);
|
||||
|
||||
int getTextureX();
|
||||
|
||||
int getTextureY();
|
||||
|
||||
IOverlayTexturedRect setTextureOffset(int var1, int var2);
|
||||
}
|
||||
@@ -0,0 +1,161 @@
|
||||
package noppes.npcs.scripted.overlay;
|
||||
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import noppes.npcs.controllers.CustomGuiController;
|
||||
import noppes.npcs.controllers.ScriptController;
|
||||
import noppes.npcs.controllers.data.PlayerDataScript;
|
||||
import noppes.npcs.scripted.entity.ScriptPlayer;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiComponent;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiItemSlot;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiLabel;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiLine;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ScriptOverlay implements ICustomOverlay {
|
||||
int id;
|
||||
int defaultAlignment = 0;
|
||||
List<ICustomOverlayComponent> components = new ArrayList();
|
||||
|
||||
public ScriptOverlay(){
|
||||
}
|
||||
|
||||
public ScriptOverlay(int id){
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<ICustomOverlayComponent> getComponents() {
|
||||
return this.components;
|
||||
}
|
||||
|
||||
public PlayerDataScript getScriptHandler() {
|
||||
return ScriptController.Instance.playerScripts;//this.scriptHandler;
|
||||
}
|
||||
|
||||
public int getDefaultAlignment(){
|
||||
return this.defaultAlignment;
|
||||
}
|
||||
|
||||
public void setDefaultAlignment(int defaultAlignment) {
|
||||
this.defaultAlignment = defaultAlignment;
|
||||
}
|
||||
|
||||
public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height) {
|
||||
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height);
|
||||
this.components.add(component);
|
||||
return (IOverlayTexturedRect)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IOverlayTexturedRect addTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
ScriptOverlayTexturedRect component = new ScriptOverlayTexturedRect(id, texture, x, y, width, height, textureX, textureY);
|
||||
this.components.add(component);
|
||||
return (IOverlayTexturedRect)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height) {
|
||||
ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height);
|
||||
this.components.add(component);
|
||||
return (IOverlayLabel)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IOverlayLabel addLabel(int id, String label, int x, int y, int width, int height, int color) {
|
||||
ScriptOverlayLabel component = new ScriptOverlayLabel(id, label, x, y, width, height, color);
|
||||
this.components.add(component);
|
||||
return (IOverlayLabel)this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IOverlayLine addLine(int id, int x1, int y1, int x2, int y2, int color, int thickness) {
|
||||
ScriptOverlayLine line = new ScriptOverlayLine(id, x1, y1, x2, y2, color, thickness);
|
||||
this.components.add(line);
|
||||
return (IOverlayLine) this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public IOverlayLine addLine(int id, int x1, int y1, int x2, int y2) {
|
||||
ScriptOverlayLine line = new ScriptOverlayLine(id, x1, y1, x2, y2);
|
||||
this.components.add(line);
|
||||
return (IOverlayLine) this.components.get(this.components.size() - 1);
|
||||
}
|
||||
|
||||
public ICustomOverlayComponent getComponent(int componentID) {
|
||||
Iterator var2 = this.components.iterator();
|
||||
|
||||
ICustomOverlayComponent component;
|
||||
do {
|
||||
if (!var2.hasNext()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
component = (ICustomOverlayComponent)var2.next();
|
||||
} while(component.getID() != componentID);
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
public void removeComponent(int componentID) {
|
||||
for(int i = 0; i < this.components.size(); ++i) {
|
||||
if (((ICustomOverlayComponent)this.components.get(i)).getID() == componentID) {
|
||||
this.components.remove(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void updateComponent(ICustomOverlayComponent component) {
|
||||
for(int i = 0; i < this.components.size(); ++i) {
|
||||
ICustomOverlayComponent c = (ICustomOverlayComponent)this.components.get(i);
|
||||
if (c.getID() == component.getID()) {
|
||||
this.components.set(i, component);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void update(IPlayer player) {
|
||||
CustomGuiController.updateOverlay((ScriptPlayer)player, this);
|
||||
}
|
||||
|
||||
public ICustomOverlay fromNBT(NBTTagCompound tag) {
|
||||
this.id = tag.getInteger("id");
|
||||
List<ICustomOverlayComponent> components = new ArrayList();
|
||||
|
||||
NBTTagList list = tag.getTagList("components", 10);
|
||||
for(int i = 0; i < list.tagCount(); i++){
|
||||
NBTBase b = list.getCompoundTagAt(i);
|
||||
ScriptOverlayComponent component = ScriptOverlayComponent.createFromNBT((NBTTagCompound)b);
|
||||
components.add(component);
|
||||
}
|
||||
|
||||
this.components = components;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT() {
|
||||
NBTTagCompound tag = new NBTTagCompound();
|
||||
tag.setInteger("id", this.id);
|
||||
|
||||
NBTTagList list = new NBTTagList();
|
||||
Iterator var3 = this.components.iterator();
|
||||
|
||||
ICustomOverlayComponent c;
|
||||
while(var3.hasNext()) {
|
||||
c = (ICustomOverlayComponent)var3.next();
|
||||
list.appendTag(((ScriptOverlayComponent)c).toNBT(new NBTTagCompound()));
|
||||
}
|
||||
|
||||
tag.setTag("components", list);
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package noppes.npcs.scripted.overlay;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import noppes.npcs.scripted.gui.*;
|
||||
import noppes.npcs.scripted.interfaces.ICustomGuiComponent;
|
||||
import noppes.npcs.scripted.interfaces.ICustomOverlayComponent;
|
||||
|
||||
public abstract class ScriptOverlayComponent implements ICustomOverlayComponent {
|
||||
int id;
|
||||
int posX;
|
||||
int posY;
|
||||
int alignment = 0;
|
||||
/* ========ALIGNMENTS========
|
||||
0 1 2
|
||||
|
||||
3 4 5
|
||||
|
||||
6 7 8
|
||||
*/
|
||||
|
||||
public ScriptOverlayComponent(){
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public ICustomOverlayComponent setID(int id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getPosX() {
|
||||
return this.posX;
|
||||
}
|
||||
|
||||
public int getPosY() {
|
||||
return this.posY;
|
||||
}
|
||||
|
||||
public ICustomOverlayComponent setPos(int x, int y) {
|
||||
this.posX = x;
|
||||
this.posY = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getAlignment() {
|
||||
return this.alignment;
|
||||
}
|
||||
|
||||
public void setAlignment(int alignment) {
|
||||
this.alignment = alignment;
|
||||
}
|
||||
|
||||
public abstract int getType();
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
nbt.setInteger("id", this.id);
|
||||
nbt.setIntArray("pos", new int[]{this.posX, this.posY});
|
||||
nbt.setInteger("alignment",this.alignment);
|
||||
|
||||
nbt.setInteger("type", this.getType());
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptOverlayComponent fromNBT(NBTTagCompound nbt) {
|
||||
this.setID(nbt.getInteger("id"));
|
||||
this.setPos(nbt.getIntArray("pos")[0], nbt.getIntArray("pos")[1]);
|
||||
this.setAlignment(nbt.getInteger("alignment"));
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public static ScriptOverlayComponent createFromNBT(NBTTagCompound nbt) {
|
||||
switch(nbt.getInteger("type")) {
|
||||
case 0:
|
||||
return (new ScriptOverlayTexturedRect()).fromNBT(nbt);
|
||||
case 1:
|
||||
return (new ScriptOverlayLabel()).fromNBT(nbt);
|
||||
case 2:
|
||||
return (new ScriptOverlayLine()).fromNBT(nbt);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package noppes.npcs.scripted.overlay;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiComponent;
|
||||
import noppes.npcs.scripted.interfaces.ILabel;
|
||||
import noppes.npcs.scripted.interfaces.IOverlayLabel;
|
||||
|
||||
public class ScriptOverlayLabel extends ScriptOverlayComponent implements IOverlayLabel {
|
||||
String label;
|
||||
int width;
|
||||
int height;
|
||||
int color;
|
||||
float scale;
|
||||
boolean shadow;
|
||||
|
||||
public ScriptOverlayLabel() {
|
||||
this.color = 16777215;
|
||||
this.scale = 1.0F;
|
||||
}
|
||||
|
||||
public ScriptOverlayLabel(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);
|
||||
this.enableShadow(false);
|
||||
}
|
||||
|
||||
public ScriptOverlayLabel(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 IOverlayLabel setText(String label) {
|
||||
this.label = label;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public IOverlayLabel setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.color;
|
||||
}
|
||||
|
||||
public IOverlayLabel setColor(int color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
public IOverlayLabel setScale(float scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasShadow(){
|
||||
return this.shadow;
|
||||
}
|
||||
|
||||
public void enableShadow(boolean shadow){
|
||||
this.shadow = shadow;
|
||||
}
|
||||
|
||||
@Override
|
||||
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);
|
||||
nbt.setBoolean("shadow",this.shadow);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptOverlayLabel 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"));
|
||||
this.enableShadow(this.shadow);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package noppes.npcs.scripted.overlay;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiComponent;
|
||||
import noppes.npcs.scripted.interfaces.IOverlayLine;
|
||||
|
||||
public class ScriptOverlayLine extends ScriptOverlayComponent implements IOverlayLine {
|
||||
int x1;
|
||||
int y1;
|
||||
int x2;
|
||||
int y2;
|
||||
int color = 0;
|
||||
int thickness = 2;
|
||||
|
||||
public ScriptOverlayLine(){
|
||||
}
|
||||
|
||||
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2){
|
||||
this.setPos(x1, y1);
|
||||
this.setID(id);
|
||||
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
}
|
||||
|
||||
public ScriptOverlayLine(int id, int x1, int y1, int x2, int y2, int color, int thickness){
|
||||
this.setPos(x1, y1);
|
||||
this.setID(id);
|
||||
|
||||
this.x1 = x1;
|
||||
this.y1 = y1;
|
||||
this.x2 = x2;
|
||||
this.y2 = y2;
|
||||
this.color = color;
|
||||
this.thickness = thickness;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public NBTTagCompound toNBT(NBTTagCompound nbt) {
|
||||
super.toNBT(nbt);
|
||||
nbt.setInteger("X1",x1);
|
||||
nbt.setInteger("Y1",y1);
|
||||
nbt.setInteger("X2",x2);
|
||||
nbt.setInteger("Y2",y2);
|
||||
nbt.setInteger("Color",color);
|
||||
nbt.setInteger("Thickness",thickness);
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
public ScriptOverlayLine fromNBT(NBTTagCompound nbt) {
|
||||
super.fromNBT(nbt);
|
||||
x1 = nbt.getInteger("X1");
|
||||
y1 = nbt.getInteger("Y1");
|
||||
x2 = nbt.getInteger("X2");
|
||||
y2 = nbt.getInteger("Y2");
|
||||
color = nbt.getInteger("Color");
|
||||
thickness = nbt.getInteger("Thickness");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getX1(){
|
||||
return this.x1;
|
||||
}
|
||||
public int getY1(){
|
||||
return this.y1;
|
||||
}
|
||||
public int getX2(){
|
||||
return this.x2;
|
||||
}
|
||||
public int getY2(){
|
||||
return this.y2;
|
||||
}
|
||||
public int getColor(){
|
||||
return this.color;
|
||||
}
|
||||
public int getThickness(){
|
||||
return this.thickness;
|
||||
}
|
||||
|
||||
public void setX1(int x1){
|
||||
this.x1 = x1;
|
||||
}
|
||||
public void setY1(int y1){
|
||||
this.y1 = y1;
|
||||
}
|
||||
public void setX2(int x2){
|
||||
this.x2 = x2;
|
||||
}
|
||||
public void setY2(int y2){
|
||||
this.y2 = y2;
|
||||
}
|
||||
public void setColor(int color){
|
||||
this.color = color;
|
||||
}
|
||||
public void setThickness(int thickness){
|
||||
this.thickness = thickness;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
package noppes.npcs.scripted.overlay;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import noppes.npcs.scripted.gui.ScriptGuiComponent;
|
||||
import noppes.npcs.scripted.interfaces.IOverlayTexturedRect;
|
||||
import noppes.npcs.scripted.interfaces.ITexturedRect;
|
||||
|
||||
public class ScriptOverlayTexturedRect extends ScriptOverlayComponent implements IOverlayTexturedRect {
|
||||
int width;
|
||||
int height;
|
||||
int textureX;
|
||||
int textureY;
|
||||
float scale;
|
||||
String texture;
|
||||
|
||||
public ScriptOverlayTexturedRect() {
|
||||
this.textureY = -1;
|
||||
this.scale = 1.0F;
|
||||
}
|
||||
|
||||
public ScriptOverlayTexturedRect(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(x, y);
|
||||
this.setSize(width, height);
|
||||
}
|
||||
|
||||
public ScriptOverlayTexturedRect(int id, String texture, int x, int y, int width, int height, int textureX, int textureY) {
|
||||
this(id, texture, x, y, width, height);
|
||||
this.setTextureOffset(textureX, textureY);
|
||||
}
|
||||
|
||||
public String getTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
public IOverlayTexturedRect setTexture(String texture) {
|
||||
this.texture = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return this.width;
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return this.height;
|
||||
}
|
||||
|
||||
public IOverlayTexturedRect setSize(int width, int height) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getScale() {
|
||||
return this.scale;
|
||||
}
|
||||
|
||||
public IOverlayTexturedRect setScale(float scale) {
|
||||
this.scale = scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getTextureX() {
|
||||
return this.textureX;
|
||||
}
|
||||
|
||||
public int getTextureY() {
|
||||
return this.textureY;
|
||||
}
|
||||
|
||||
public IOverlayTexturedRect setTextureOffset(int offsetX, int offsetY) {
|
||||
this.textureX = offsetX;
|
||||
this.textureY = offsetY;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getType() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
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 ScriptOverlayComponent 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;
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ import noppes.npcs.scripted.entity.*;
|
||||
import noppes.npcs.scripted.gui.ScriptGui;
|
||||
import noppes.npcs.scripted.handler.*;
|
||||
import noppes.npcs.scripted.interfaces.*;
|
||||
import noppes.npcs.scripted.overlay.ScriptOverlay;
|
||||
import noppes.npcs.util.JsonException;
|
||||
import noppes.npcs.util.LRUHashMap;
|
||||
import noppes.npcs.util.NBTJsonUtil;
|
||||
@@ -275,4 +276,8 @@ public class WrapperNpcAPI extends NpcAPI {
|
||||
public ICustomGui createCustomGui(int id, int width, int height, boolean pauseGame) {
|
||||
return new ScriptGui(id, width, height, pauseGame);
|
||||
}
|
||||
|
||||
public ICustomOverlay createCustomOverlay(int id) {
|
||||
return new ScriptOverlay(id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user