mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-24 02:29:41 +00:00
Animated Texture Support
This commit is contained in:
1 parent
988dbe0cd2
commit
de2fcea154
17 files changed
+578
-21
No files matched your search
@@ -11,6 +11,11 @@ public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITextur
|
||||
float scale;
|
||||
String texture;
|
||||
|
||||
// Animation
|
||||
boolean animated = false;
|
||||
int frameCount = 1;
|
||||
int frametime = 2;
|
||||
|
||||
public ScriptGuiTexturedRect() {
|
||||
this.textureY = -1;
|
||||
this.scale = 1.0F;
|
||||
@@ -76,6 +81,25 @@ public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITextur
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAnimated() {
|
||||
return this.animated && this.frameCount > 1;
|
||||
}
|
||||
|
||||
public int getFrameCount() {
|
||||
return this.frameCount;
|
||||
}
|
||||
|
||||
public int getFrameTime() {
|
||||
return this.frametime;
|
||||
}
|
||||
|
||||
public ITexturedRect setAnimation(int frameCount, int frametime) {
|
||||
this.animated = frameCount > 1;
|
||||
this.frameCount = Math.max(1, frameCount);
|
||||
this.frametime = Math.max(1, frametime);
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return 2;
|
||||
}
|
||||
@@ -89,6 +113,12 @@ public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITextur
|
||||
nbt.setIntArray("texPos", new int[]{this.textureX, this.textureY});
|
||||
}
|
||||
|
||||
if (this.animated) {
|
||||
nbt.setBoolean("animated", true);
|
||||
nbt.setInteger("frameCount", this.frameCount);
|
||||
nbt.setInteger("frameTime", this.frametime);
|
||||
}
|
||||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
@@ -101,6 +131,13 @@ public class ScriptGuiTexturedRect extends ScriptGuiComponent implements ITextur
|
||||
this.setTextureOffset(nbt.getIntArray("texPos")[0], nbt.getIntArray("texPos")[1]);
|
||||
}
|
||||
|
||||
if (nbt.hasKey("animated") && nbt.getBoolean("animated")) {
|
||||
this.setAnimation(
|
||||
nbt.hasKey("frameCount") ? Math.max(1, nbt.getInteger("frameCount")) : 1,
|
||||
nbt.hasKey("frameTime") ? Math.max(1, nbt.getInteger("frameTime")) : 2
|
||||
);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user