Files
CustomNPC-Plus/src/main/java/noppes/npcs/entity/data/ModelPartData.java
T

78 lines
2.1 KiB
Java
Raw Normal View History

package noppes.npcs.entity.data;
2018-09-13 12:03:28 -04:00
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
public class ModelPartData {
2025-03-12 20:12:01 -04:00
public int color = 0xFFFFFF;
public String texture;
public byte type = 0;
2024-03-20 14:24:08 -04:00
public byte pattern = 0;
2025-03-12 20:12:01 -04:00
public boolean playerTexture;
2025-03-12 20:12:01 -04:00
private ResourceLocation location;
2025-03-12 20:12:01 -04:00
public ModelPartData() {
playerTexture = true;
}
2018-09-13 12:03:28 -04:00
2025-03-12 20:12:01 -04:00
public ModelPartData(String texture) {
this.texture = texture;
playerTexture = false;
}
2018-09-13 12:03:28 -04:00
2025-03-12 20:12:01 -04:00
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Type", type);
compound.setInteger("Color", color);
2024-03-20 14:24:08 -04:00
compound.setByte("Pattern", pattern);
2025-03-12 20:12:01 -04:00
if (texture != null && !texture.isEmpty()) {
compound.setString("Texture", texture);
}
compound.setBoolean("PlayerTexture", playerTexture);
return compound;
}
2025-03-12 20:12:01 -04:00
public void readFromNBT(NBTTagCompound compound) {
type = compound.getByte("Type");
color = compound.getInteger("Color");
texture = compound.getString("Texture");
2024-03-20 14:24:08 -04:00
pattern = compound.getByte("Pattern");
2025-03-12 20:12:01 -04:00
playerTexture = compound.getBoolean("PlayerTexture");
location = null;
}
2025-03-12 20:12:01 -04:00
public ResourceLocation getResource() {
if (texture.isEmpty())
return null;
if (location != null)
return location;
location = new ResourceLocation(texture);
return location;
}
2018-09-13 12:03:28 -04:00
2025-03-12 20:12:01 -04:00
public void setTexture(String texture, int type) {
this.type = (byte) type;
this.location = null;
if (texture.isEmpty()) {
playerTexture = true;
this.texture = texture;
} else {
this.texture = "customnpcs:textures/parts/" + texture + ".png";
playerTexture = false;
}
}
2025-03-12 20:12:01 -04:00
public String toString() {
return "Color: " + color + " Type: " + type;
}
2018-09-13 12:03:28 -04:00
2025-03-12 20:12:01 -04:00
public String getColor() {
String str = Integer.toHexString(color);
2018-09-13 12:03:28 -04:00
2025-03-12 20:12:01 -04:00
while (str.length() < 6)
str = "0" + str;
2025-03-12 20:12:01 -04:00
return str;
}
2024-03-20 14:24:08 -04:00
}