mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 05:27:37 +00:00
NBT changes to accommodate nullable fields
This commit is contained in:
1 parent
82dfbc8635
commit
fb75f52806
1 file changed
+118
-68
@@ -57,108 +57,108 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack {
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public boolean getDurabilityShow() {
|
||||
return this.itemDisplay.durabilityShow;
|
||||
public Boolean getDurabilityShow() {
|
||||
return this.itemDisplay.durabilityShow != null ? this.itemDisplay.durabilityShow : false;
|
||||
}
|
||||
|
||||
public void setDurabilityShow(boolean bo) {
|
||||
public void setDurabilityShow(Boolean bo) {
|
||||
this.itemDisplay.durabilityShow = bo;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public int getDurabilityColor() {
|
||||
return this.itemDisplay.durabilityColor;
|
||||
public Integer getDurabilityColor() {
|
||||
return this.itemDisplay.durabilityColor != null ? this.itemDisplay.durabilityColor : -1;
|
||||
}
|
||||
|
||||
public void setDurabilityColor(int color) {
|
||||
public void setDurabilityColor(Integer color) {
|
||||
this.itemDisplay.durabilityColor = color;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return this.itemDisplay.itemColor;
|
||||
public Integer getColor() {
|
||||
return this.itemDisplay.itemColor != null ? this.itemDisplay.itemColor : 0x8B4513;
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
public void setColor(Integer color) {
|
||||
this.itemDisplay.itemColor = color;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
|
||||
public void setRotation(float rotationX, float rotationY, float rotationZ){
|
||||
public void setRotation(Float rotationX, Float rotationY, Float rotationZ){
|
||||
this.itemDisplay.rotationX = rotationX;
|
||||
this.itemDisplay.rotationY = rotationY;
|
||||
this.itemDisplay.rotationZ = rotationZ;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setRotationRate(float rotationXRate, float rotationYRate, float rotationZRate){
|
||||
public void setRotationRate(Float rotationXRate, Float rotationYRate, Float rotationZRate){
|
||||
this.itemDisplay.rotationXRate = rotationXRate;
|
||||
this.itemDisplay.rotationYRate = rotationYRate;
|
||||
this.itemDisplay.rotationZRate = rotationZRate;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setScale(float scaleX, float scaleY, float scaleZ){
|
||||
public void setScale(Float scaleX, Float scaleY, Float scaleZ){
|
||||
this.itemDisplay.scaleX = scaleX;
|
||||
this.itemDisplay.scaleY = scaleY;
|
||||
this.itemDisplay.scaleZ = scaleZ;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public void setTranslate(float translateX, float translateY, float translateZ){
|
||||
public void setTranslate(Float translateX, Float translateY, Float translateZ){
|
||||
this.itemDisplay.translateX = translateX;
|
||||
this.itemDisplay.translateY = translateY;
|
||||
this.itemDisplay.translateZ = translateZ;
|
||||
saveItemData();
|
||||
}
|
||||
|
||||
public float getRotationX() {
|
||||
return this.itemDisplay.rotationX;
|
||||
public Float getRotationX() {
|
||||
return this.itemDisplay.rotationX != null ? this.itemDisplay.rotationX : 0;
|
||||
}
|
||||
|
||||
public float getRotationY() {
|
||||
return this.itemDisplay.rotationY;
|
||||
public Float getRotationY() {
|
||||
return this.itemDisplay.rotationY != null ? this.itemDisplay.rotationY : 0;
|
||||
}
|
||||
|
||||
public float getRotationZ() {
|
||||
return this.itemDisplay.rotationZ;
|
||||
public Float getRotationZ() {
|
||||
return this.itemDisplay.rotationZ != null ? this.itemDisplay.rotationZ : 0;
|
||||
}
|
||||
|
||||
public float getRotationXRate() {
|
||||
return this.itemDisplay.rotationXRate;
|
||||
public Float getRotationXRate() {
|
||||
return this.itemDisplay.rotationXRate != null ? this.itemDisplay.rotationXRate : 0;
|
||||
}
|
||||
|
||||
public float getRotationYRate() {
|
||||
return this.itemDisplay.rotationYRate;
|
||||
public Float getRotationYRate() {
|
||||
return this.itemDisplay.rotationYRate != null ? this.itemDisplay.rotationYRate : 0;
|
||||
}
|
||||
|
||||
public float getRotationZRate() {
|
||||
return this.itemDisplay.rotationZRate;
|
||||
public Float getRotationZRate() {
|
||||
return this.itemDisplay.rotationZRate != null ? this.itemDisplay.rotationZRate : 0;
|
||||
}
|
||||
|
||||
public float getScaleX() {
|
||||
return this.itemDisplay.scaleX;
|
||||
public Float getScaleX() {
|
||||
return this.itemDisplay.scaleX != null ? this.itemDisplay.scaleX : 0;
|
||||
}
|
||||
|
||||
public float getScaleY() {
|
||||
return this.itemDisplay.scaleY;
|
||||
public Float getScaleY() {
|
||||
return this.itemDisplay.scaleY != null ? this.itemDisplay.scaleY : 0;
|
||||
}
|
||||
|
||||
public float getScaleZ() {
|
||||
return this.itemDisplay.scaleZ;
|
||||
public Float getScaleZ() {
|
||||
return this.itemDisplay.scaleZ != null ? this.itemDisplay.scaleZ : 0;
|
||||
}
|
||||
|
||||
public float getTranslateX() {
|
||||
return this.itemDisplay.translateX;
|
||||
public Float getTranslateX() {
|
||||
return this.itemDisplay.translateX != null ? this.itemDisplay.translateX : 0;
|
||||
}
|
||||
|
||||
public float getTranslateY() {
|
||||
return this.itemDisplay.translateY;
|
||||
public Float getTranslateY() {
|
||||
return this.itemDisplay.translateY != null ? this.itemDisplay.translateY : 0;
|
||||
}
|
||||
|
||||
public float getTranslateZ() {
|
||||
return this.itemDisplay.translateZ;
|
||||
public Float getTranslateZ() {
|
||||
return this.itemDisplay.translateZ != null ? this.itemDisplay.translateZ : 0;
|
||||
}
|
||||
|
||||
public NBTTagCompound getMCNbt() {
|
||||
@@ -188,52 +188,102 @@ public abstract class ScriptCustomizableItem extends ScriptItemStack {
|
||||
}
|
||||
|
||||
public NBTTagCompound getItemNBT(NBTTagCompound compound) {
|
||||
compound.setBoolean("DurabilityShow",this.itemDisplay.durabilityShow);
|
||||
compound.setInteger("DurabilityColor",this.itemDisplay.durabilityColor );
|
||||
compound.setInteger("ItemColor",this.itemDisplay.itemColor);
|
||||
compound.setString("ItemTexture",this.itemDisplay.texture);
|
||||
this.setBoolean(compound, "DurabilityShow",this.itemDisplay.durabilityShow);
|
||||
this.setInteger(compound, "DurabilityColor",this.itemDisplay.durabilityColor);
|
||||
this.setInteger(compound, "ItemColor",this.itemDisplay.itemColor);
|
||||
if (this.itemDisplay.texture != null) {
|
||||
compound.setString("ItemTexture", this.itemDisplay.texture);
|
||||
}
|
||||
|
||||
compound.setFloat("RotationX",this.itemDisplay.rotationX);
|
||||
compound.setFloat("RotationY",this.itemDisplay.rotationY);
|
||||
compound.setFloat("RotationZ",this.itemDisplay.rotationZ);
|
||||
this.setFloat(compound, "RotationX",this.itemDisplay.rotationX);
|
||||
this.setFloat(compound, "RotationY",this.itemDisplay.rotationY);
|
||||
this.setFloat(compound, "RotationZ",this.itemDisplay.rotationZ);
|
||||
|
||||
compound.setFloat("RotationXRate",this.itemDisplay.rotationXRate);
|
||||
compound.setFloat("RotationYRate",this.itemDisplay.rotationYRate);
|
||||
compound.setFloat("RotationZRate",this.itemDisplay.rotationZRate);
|
||||
this.setFloat(compound, "RotationXRate",this.itemDisplay.rotationXRate);
|
||||
this.setFloat(compound, "RotationYRate",this.itemDisplay.rotationYRate);
|
||||
this.setFloat(compound, "RotationZRate",this.itemDisplay.rotationZRate);
|
||||
|
||||
compound.setFloat("ScaleX",this.itemDisplay.scaleX);
|
||||
compound.setFloat("ScaleY",this.itemDisplay.scaleY);
|
||||
compound.setFloat("ScaleZ",this.itemDisplay.scaleZ);
|
||||
this.setFloat(compound, "ScaleX",this.itemDisplay.scaleX);
|
||||
this.setFloat(compound, "ScaleY",this.itemDisplay.scaleY);
|
||||
this.setFloat(compound, "ScaleZ",this.itemDisplay.scaleZ);
|
||||
|
||||
compound.setFloat("TranslateX",this.itemDisplay.translateX);
|
||||
compound.setFloat("TranslateY",this.itemDisplay.translateY);
|
||||
compound.setFloat("TranslateZ",this.itemDisplay.translateZ);
|
||||
this.setFloat(compound, "TranslateX",this.itemDisplay.translateX);
|
||||
this.setFloat(compound, "TranslateY",this.itemDisplay.translateY);
|
||||
this.setFloat(compound, "TranslateZ",this.itemDisplay.translateZ);
|
||||
return compound;
|
||||
}
|
||||
|
||||
private void setBoolean(NBTTagCompound compound, String key, Boolean value) {
|
||||
if (value != null) {
|
||||
compound.setBoolean(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void setInteger(NBTTagCompound compound, String key, Integer value) {
|
||||
if (value != null) {
|
||||
compound.setInteger(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void setFloat(NBTTagCompound compound, String key, Float value) {
|
||||
if (value != null) {
|
||||
compound.setFloat(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
public void setItemNBT(NBTTagCompound compound) {
|
||||
this.itemDisplay.durabilityShow = compound.getBoolean("DurabilityShow");
|
||||
if (compound.hasKey("DurabilityShow")) {
|
||||
this.itemDisplay.durabilityShow = compound.getBoolean("DurabilityShow");
|
||||
}
|
||||
if (compound.hasKey("DurabilityColor")) {
|
||||
this.itemDisplay.durabilityColor = compound.getInteger("DurabilityColor");
|
||||
}
|
||||
this.itemDisplay.itemColor = compound.getInteger("ItemColor");
|
||||
this.itemDisplay.texture = compound.getString("ItemTexture");
|
||||
if (compound.hasKey("ItemColor")) {
|
||||
this.itemDisplay.itemColor = compound.getInteger("ItemColor");
|
||||
}
|
||||
if (compound.hasKey("ItemTexture")) {
|
||||
this.itemDisplay.texture = compound.getString("ItemTexture");
|
||||
}
|
||||
|
||||
this.itemDisplay.rotationX = compound.getFloat("RotationX");
|
||||
this.itemDisplay.rotationY = compound.getFloat("RotationY");
|
||||
this.itemDisplay.rotationZ = compound.getFloat("RotationZ");
|
||||
if (compound.hasKey("RotationX")) {
|
||||
this.itemDisplay.rotationX = compound.getFloat("RotationX");
|
||||
}
|
||||
if (compound.hasKey("RotationY")) {
|
||||
this.itemDisplay.rotationY = compound.getFloat("RotationY");
|
||||
}
|
||||
if (compound.hasKey("RotationZ")) {
|
||||
this.itemDisplay.rotationZ = compound.getFloat("RotationZ");
|
||||
}
|
||||
|
||||
this.itemDisplay.rotationXRate = compound.getFloat("RotationXRate");
|
||||
this.itemDisplay.rotationYRate = compound.getFloat("RotationYRate");
|
||||
this.itemDisplay.rotationZRate = compound.getFloat("RotationZRate");
|
||||
if (compound.hasKey("RotationXRate")) {
|
||||
this.itemDisplay.rotationXRate = compound.getFloat("RotationXRate");
|
||||
}
|
||||
if (compound.hasKey("RotationYRate")) {
|
||||
this.itemDisplay.rotationYRate = compound.getFloat("RotationYRate");
|
||||
}
|
||||
if (compound.hasKey("RotationZRate")) {
|
||||
this.itemDisplay.rotationZRate = compound.getFloat("RotationZRate");
|
||||
}
|
||||
|
||||
this.itemDisplay.scaleX = compound.getFloat("ScaleX");
|
||||
this.itemDisplay.scaleY = compound.getFloat("ScaleY");
|
||||
this.itemDisplay.scaleZ = compound.getFloat("ScaleZ");
|
||||
if (compound.hasKey("ScaleX")) {
|
||||
this.itemDisplay.scaleX = compound.getFloat("ScaleX");
|
||||
}
|
||||
if (compound.hasKey("ScaleY")) {
|
||||
this.itemDisplay.scaleY = compound.getFloat("ScaleY");
|
||||
}
|
||||
if (compound.hasKey("ScaleZ")) {
|
||||
this.itemDisplay.scaleZ = compound.getFloat("ScaleZ");
|
||||
}
|
||||
|
||||
this.itemDisplay.translateX = compound.getFloat("TranslateX");
|
||||
this.itemDisplay.translateY = compound.getFloat("TranslateY");
|
||||
this.itemDisplay.translateZ = compound.getFloat("TranslateZ");
|
||||
if (compound.hasKey("TranslateX")) {
|
||||
this.itemDisplay.translateX = compound.getFloat("TranslateX");
|
||||
}
|
||||
if (compound.hasKey("TranslateY")) {
|
||||
this.itemDisplay.translateY = compound.getFloat("TranslateY");
|
||||
}
|
||||
if (compound.hasKey("TranslateZ")) {
|
||||
this.itemDisplay.translateZ = compound.getFloat("TranslateZ");
|
||||
}
|
||||
}
|
||||
|
||||
public static class Display {
|
||||
|
||||
Reference in new issue
Block a user