Animated Texture Support

This commit is contained in:
Kam committed 2026-02-28 18:34:21 -05:00
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;
}
}
@@ -147,6 +147,33 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack implements
return this.itemDisplay.translateZ != null ? this.itemDisplay.translateZ : 0;
}
public Boolean isTextureAnimated() {
return this.itemDisplay.animated != null ? this.itemDisplay.animated : false;
}
public void setTextureAnimated(Boolean animated) {
this.itemDisplay.animated = animated;
saveItemData();
}
public Integer getFrameCount() {
return this.itemDisplay.frameCount != null ? this.itemDisplay.frameCount : 1;
}
public void setFrameCount(Integer frameCount) {
this.itemDisplay.frameCount = frameCount != null ? Math.max(1, frameCount) : 1;
saveItemData();
}
public Integer getFrameTime() {
return this.itemDisplay.frametime != null ? this.itemDisplay.frametime : 2;
}
public void setFrameTime(Integer frametime) {
this.itemDisplay.frametime = frametime != null ? Math.max(1, frametime) : 2;
saveItemData();
}
public NBTTagCompound getMCNbt() {
NBTTagCompound compound = super.getMCNbt();
compound.setTag("ItemData", this.getItemNBT(new NBTTagCompound()));