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

76 lines
1.7 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 {
public int color = 0xFFFFFF;
public String texture;
public byte type = 0;
public boolean playerTexture;
2018-09-13 12:03:28 -04:00
private ResourceLocation location;
2018-09-13 12:03:28 -04:00
public ModelPartData(){
playerTexture = true;
}
public ModelPartData(String texture) {
this.texture = texture;
playerTexture = false;
}
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Type", type);
compound.setInteger("Color", color);
if(texture != null && !texture.isEmpty()) {
2018-09-13 12:03:28 -04:00
compound.setString("Texture", texture);
}
2018-09-13 12:03:28 -04:00
compound.setBoolean("PlayerTexture", playerTexture);
return compound;
}
2018-09-13 12:03:28 -04:00
public void readFromNBT(NBTTagCompound compound){
type = compound.getByte("Type");
color = compound.getInteger("Color");
texture = compound.getString("Texture");
playerTexture = compound.getBoolean("PlayerTexture");
location = null;
}
2018-09-13 12:03:28 -04:00
public ResourceLocation getResource(){
if(texture.isEmpty())
return null;
if(location != null)
return location;
location = new ResourceLocation(texture);
2018-09-13 12:03:28 -04:00
return location;
}
public void setTexture(String texture, int type) {
this.type = (byte) type;
this.location = null;
if(texture.isEmpty()){
playerTexture = true;
this.texture = texture;
}
else{
2021-05-02 22:53:03 -04:00
this.texture = "customnpcs:textures/parts/"+ texture + ".png";
2018-09-13 12:03:28 -04:00
playerTexture = false;
}
}
2018-09-13 12:03:28 -04:00
public String toString(){
return "Color: " + color + " Type: " + type;
}
public String getColor() {
String str = Integer.toHexString(color);
while(str.length() < 6)
str = "0" + str;
return str;
}
}