Proper Reformating

This commit is contained in:
Kam committed 2025-03-13 17:14:45 -04:00
1 parent ce75880aba
commit 180d257024
1179 files changed
+59847 -61583

No files matched your search

@@ -23,8 +23,8 @@ public class DataSkinOverlays implements IOverlayHandler {
}
public void readFromNBT(NBTTagCompound nbtTagCompound) {
HashMap<Integer,ISkinOverlay> skinOverlays = new HashMap<>();
NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData",10);
HashMap<Integer, ISkinOverlay> skinOverlays = new HashMap<>();
NBTTagList skinOverlayList = nbtTagCompound.getTagList("SkinOverlayData", 10);
for (int i = 0; i < skinOverlayList.tagCount(); i++) {
int tagID = skinOverlayList.getCompoundTagAt(i).getInteger("SkinOverlayID");
SkinOverlay skinOverlay = (SkinOverlay) SkinOverlay.overlayFromNBT(skinOverlayList.getCompoundTagAt(i));
@@ -38,14 +38,14 @@ public class DataSkinOverlays implements IOverlayHandler {
public NBTTagCompound writeToNBT(NBTTagCompound nbttagcompound) {
NBTTagList overlayList = new NBTTagList();
if (!this.overlayList.isEmpty()) {
for (Map.Entry<Integer,ISkinOverlay> overlayData : this.overlayList.entrySet()) {
for (Map.Entry<Integer, ISkinOverlay> overlayData : this.overlayList.entrySet()) {
NBTTagCompound compound = new NBTTagCompound();
compound.setInteger("SkinOverlayID", overlayData.getKey());
compound = ((SkinOverlay) overlayData.getValue()).writeToNBT(compound);
overlayList.appendTag(compound);
}
}
nbttagcompound.setTag("SkinOverlayData",overlayList);
nbttagcompound.setTag("SkinOverlayData", overlayList);
return nbttagcompound;
}
@@ -85,7 +85,9 @@ public class DataSkinOverlays implements IOverlayHandler {
return removed;
}
public int size() { return this.overlayList.size(); }
public int size() {
return this.overlayList.size();
}
public void clear() {
this.overlayList.clear();
@@ -31,7 +31,7 @@ public class DataTimers implements ITimers {
}
public void start(int id, int ticks, boolean repeat) {
if(this.timers.containsKey(id)) {
if (this.timers.containsKey(id)) {
throw new CustomNPCsException("There is already a timer with id: " + id);
} else {
this.timers.put(id, new DataTimers.Timer(id, ticks, repeat));
@@ -56,46 +56,46 @@ public class DataTimers implements ITimers {
timer.ticks = 0;
}
public int ticks(int id){
public int ticks(int id) {
this.timerException(id);
return this.timers.get(id).ticks;
}
public void setTicks(int id, int ticks){
public void setTicks(int id, int ticks) {
this.timerException(id);
DataTimers.Timer timer = this.timers.get(id);
if(ticks < 0)
if (ticks < 0)
ticks = 0;
if(ticks > timer.timerTicks)
if (ticks > timer.timerTicks)
ticks = timer.timerTicks;
timer.ticks = ticks;
}
public int maxTicks(int id){
public int maxTicks(int id) {
this.timerException(id);
return this.timers.get(id).timerTicks;
}
public void setMaxTicks(int id, int maxTicks){
public void setMaxTicks(int id, int maxTicks) {
this.timerException(id);
DataTimers.Timer timer = this.timers.get(id);
if(maxTicks < 0)
if (maxTicks < 0)
maxTicks = 0;
if(timer.ticks > maxTicks)
if (timer.ticks > maxTicks)
timer.ticks = maxTicks;
timer.timerTicks = maxTicks;
}
public boolean repeats(int id){
public boolean repeats(int id) {
this.timerException(id);
return this.timers.get(id).repeat;
}
public void setRepeats(int id, boolean repeat){
public void setRepeats(int id, boolean repeat) {
this.timerException(id);
this.timers.get(id).repeat = repeat;
}
@@ -104,8 +104,8 @@ public class DataTimers implements ITimers {
NBTTagList list = new NBTTagList();
Iterator var3 = this.timers.values().iterator();
while(var3.hasNext()) {
DataTimers.Timer timer = (DataTimers.Timer)var3.next();
while (var3.hasNext()) {
DataTimers.Timer timer = (DataTimers.Timer) var3.next();
NBTTagCompound c = new NBTTagCompound();
c.setInteger("ID", timer.id);
c.setInteger("TimerTicks", timer.timerTicks);
@@ -127,7 +127,7 @@ public class DataTimers implements ITimers {
HashMap<Integer, DataTimers.Timer> timers = new HashMap<>();
NBTTagList list = compound.getTagList("NpcsTimers", 10);
if(list != null) {
if (list != null) {
for (int i = 0; i < list.tagCount(); ++i) {
NBTTagCompound c = list.getCompoundTagAt(i);
DataTimers.Timer t = new DataTimers.Timer(c.getInteger("ID"), c.getInteger("TimerTicks"), c.getBoolean("Repeat"));
@@ -152,7 +152,9 @@ public class DataTimers implements ITimers {
this.timers = new HashMap<>();
}
public int size() { return this.timers.size(); }
public int size() {
return this.timers.size();
}
class Timer {
public int id;
@@ -168,8 +170,8 @@ public class DataTimers implements ITimers {
}
public void update() {
if(this.ticks-- <= 0) {
if(this.repeat) {
if (this.ticks-- <= 0) {
if (this.repeat) {
this.ticks = this.timerTicks;
} else {
DataTimers.this.stop(this.id);
@@ -177,13 +179,11 @@ public class DataTimers implements ITimers {
Object ob = DataTimers.this.parent;
if (ob instanceof EntityNPCInterface) {
EventHooks.onNPCTimer((EntityNPCInterface)ob, this.id);
}
else if(ob instanceof PlayerData) {
EventHooks.onPlayerTimer((PlayerData)ob, this.id);
}
else if(ob instanceof TileScripted) {
EventHooks.onScriptBlockTimer((TileScripted)ob, this.id);
EventHooks.onNPCTimer((EntityNPCInterface) ob, this.id);
} else if (ob instanceof PlayerData) {
EventHooks.onPlayerTimer((PlayerData) ob, this.id);
} else if (ob instanceof TileScripted) {
EventHooks.onScriptBlockTimer((TileScripted) ob, this.id);
}
}
}
@@ -6,40 +6,40 @@ import net.minecraft.world.World;
import noppes.npcs.compat.PixelmonHelper;
import noppes.npcs.entity.EntityNPCInterface;
public class ModelData extends ModelDataShared{
public EntityLivingBase getEntity(EntityNPCInterface npc){
if(entityClass == null)
return null;
if(entity == null){
try {
entity = entityClass.getConstructor(new Class[] {World.class}).newInstance(new Object[] {npc.worldObj});
public class ModelData extends ModelDataShared {
entity.readEntityFromNBT(extra);
if(entity instanceof EntityLiving){
EntityLiving living = (EntityLiving)entity;
living.setCurrentItemOrArmor(0, npc.getHeldItem() != null?npc.getHeldItem():npc.getOffHand());
living.setCurrentItemOrArmor(1, npc.inventory.armorItemInSlot(3));
living.setCurrentItemOrArmor(2, npc.inventory.armorItemInSlot(2));
living.setCurrentItemOrArmor(3, npc.inventory.armorItemInSlot(1));
living.setCurrentItemOrArmor(4, npc.inventory.armorItemInSlot(0));
}
if(PixelmonHelper.isPixelmon(entity) && npc.worldObj.isRemote){
if(extra.hasKey("Name"))
PixelmonHelper.setName(entity, extra.getString("Name"));
else
PixelmonHelper.setName(entity, "Abra");
}
} catch (Exception e) {
}
}
return entity;
}
public ModelData copy(){
ModelData data = new ModelData();
data.readFromNBT(this.writeToNBT());
return data;
}
public EntityLivingBase getEntity(EntityNPCInterface npc) {
if (entityClass == null)
return null;
if (entity == null) {
try {
entity = entityClass.getConstructor(new Class[]{World.class}).newInstance(new Object[]{npc.worldObj});
entity.readEntityFromNBT(extra);
if (entity instanceof EntityLiving) {
EntityLiving living = (EntityLiving) entity;
living.setCurrentItemOrArmor(0, npc.getHeldItem() != null ? npc.getHeldItem() : npc.getOffHand());
living.setCurrentItemOrArmor(1, npc.inventory.armorItemInSlot(3));
living.setCurrentItemOrArmor(2, npc.inventory.armorItemInSlot(2));
living.setCurrentItemOrArmor(3, npc.inventory.armorItemInSlot(1));
living.setCurrentItemOrArmor(4, npc.inventory.armorItemInSlot(0));
}
if (PixelmonHelper.isPixelmon(entity) && npc.worldObj.isRemote) {
if (extra.hasKey("Name"))
PixelmonHelper.setName(entity, extra.getString("Name"));
else
PixelmonHelper.setName(entity, "Abra");
}
} catch (Exception e) {
}
}
return entity;
}
public ModelData copy() {
ModelData data = new ModelData();
data.readFromNBT(this.writeToNBT());
return data;
}
}
@@ -13,403 +13,404 @@ import java.util.HashMap;
public class ModelDataShared implements IModelData {
public ModelScale modelScale = new ModelScale();
public ModelScale modelScale = new ModelScale();
public boolean enableRotation = false;
public ModelRotate rotation = new ModelRotate();
public boolean enableRotation = false;
public ModelRotate rotation = new ModelRotate();
public ModelPartData legParts = new ModelPartData();
public Class<? extends EntityLivingBase> entityClass;
public EntityLivingBase entity;
public NBTTagCompound extra = new NBTTagCompound();
private HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
public byte breasts = 0;
public ModelPartData legParts = new ModelPartData();
public byte headwear = 2;
public byte bodywear = 0;
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
public byte armwear = 0;
public byte legwear = 0;
public Class<? extends EntityLivingBase> entityClass;
public EntityLivingBase entity;
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
public byte solidArmwear = 0;
public byte solidLegwear = 0;
public NBTTagCompound extra = new NBTTagCompound();
// Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left],
public byte hideHead = 0;
public byte hideBody = 0;
public byte hideArms = 0;
public byte hideLegs = 0;
private HashMap<String, ModelPartData> parts = new HashMap<String, ModelPartData>();
public byte breasts = 0;
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
public byte headwear = 2;
public byte bodywear = 0;
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
public byte armwear = 0;
public byte legwear = 0;
if(entityClass != null)
compound.setString("EntityClass", entityClass.getCanonicalName());
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
public byte solidArmwear = 0;
public byte solidLegwear = 0;
compound = this.modelScale.writeToNBT(compound);
// Hide Body Parts [0: None, 1: Both, 2: Right, 3: Left],
public byte hideHead = 0;
public byte hideBody = 0;
public byte hideArms = 0;
public byte hideLegs = 0;
compound.setTag("LegParts", legParts.writeToNBT());
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Headwear", headwear);
compound.setByte("Bodywear", bodywear);
compound.setByte("Armwear", armwear);
compound.setByte("Legwear", legwear);
if (entityClass != null)
compound.setString("EntityClass", entityClass.getCanonicalName());
compound.setByte("SolidArmwear", solidArmwear);
compound.setByte("SolidLegwear", solidLegwear);
compound = this.modelScale.writeToNBT(compound);
compound.setByte("hideHead", hideHead);
compound.setByte("hideBody", hideBody);
compound.setByte("hideArms", hideArms);
compound.setByte("hideLegs", hideLegs);
compound.setTag("LegParts", legParts.writeToNBT());
compound.setBoolean("EnableRotation", enableRotation);
if(enableRotation)
compound.setTag("ModelRotation", rotation.writeToNBT());
compound.setByte("Headwear", headwear);
compound.setByte("Bodywear", bodywear);
compound.setByte("Armwear", armwear);
compound.setByte("Legwear", legwear);
compound.setByte("Breasts", breasts);
compound.setTag("ExtraData", extra);
compound.setByte("SolidArmwear", solidArmwear);
compound.setByte("SolidLegwear", solidLegwear);
NBTTagList list = new NBTTagList();
for(String name : parts.keySet()){
NBTTagCompound item = parts.get(name).writeToNBT();
item.setString("PartName", name);
list.appendTag(item);
}
compound.setTag("Parts", list);
return compound;
}
compound.setByte("hideHead", hideHead);
compound.setByte("hideBody", hideBody);
compound.setByte("hideArms", hideArms);
compound.setByte("hideLegs", hideLegs);
public void readFromNBT(NBTTagCompound compound){
setEntity(compound.getString("EntityClass"));
compound.setBoolean("EnableRotation", enableRotation);
if (enableRotation)
compound.setTag("ModelRotation", rotation.writeToNBT());
this.modelScale.readFromNBT(compound);
compound.setByte("Breasts", breasts);
compound.setTag("ExtraData", extra);
legParts.readFromNBT(compound.getCompoundTag("LegParts"));
NBTTagList list = new NBTTagList();
for (String name : parts.keySet()) {
NBTTagCompound item = parts.get(name).writeToNBT();
item.setString("PartName", name);
list.appendTag(item);
}
compound.setTag("Parts", list);
headwear = compound.getByte("Headwear");
bodywear = compound.getByte("Bodywear");
armwear = compound.getByte("Armwear");
legwear = compound.getByte("Legwear");
return compound;
}
solidArmwear = compound.getByte("SolidArmwear");
solidLegwear = compound.getByte("SolidLegwear");
public void readFromNBT(NBTTagCompound compound) {
setEntity(compound.getString("EntityClass"));
hideHead = compound.getByte("hideHead");
hideBody = compound.getByte("hideBody");
hideArms = compound.getByte("hideArms");
hideLegs = compound.getByte("hideLegs");
this.modelScale.readFromNBT(compound);
enableRotation = compound.getBoolean("EnableRotation");
if(enableRotation)
rotation.readFromNBT(compound.getCompoundTag("ModelRotation"));
legParts.readFromNBT(compound.getCompoundTag("LegParts"));
breasts = compound.getByte("Breasts");
extra = compound.getCompoundTag("ExtraData");
headwear = compound.getByte("Headwear");
bodywear = compound.getByte("Bodywear");
armwear = compound.getByte("Armwear");
legwear = compound.getByte("Legwear");
HashMap<String,ModelPartData> parts = new HashMap<String,ModelPartData>();
NBTTagList list = compound.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
ModelPartData part = new ModelPartData();
part.readFromNBT(item);
parts.put(item.getString("PartName"), part);
}
this.parts = parts;
}
public void setEntityClass(Class<? extends EntityLivingBase> entityClass){
this.entityClass = entityClass;
entity = null;
extra = new NBTTagCompound();
if(entityClass == EntityHorse.class)
extra.setInteger("Type", -1);
}
public Class<? extends EntityLivingBase> getEntityClass(){
return entityClass;
}
solidArmwear = compound.getByte("SolidArmwear");
solidLegwear = compound.getByte("SolidLegwear");
public float offsetY() {
if(entity == null)
return -getBodyY();
return entity.height - 1.8f;
}
hideHead = compound.getByte("hideHead");
hideBody = compound.getByte("hideBody");
hideArms = compound.getByte("hideArms");
hideLegs = compound.getByte("hideLegs");
public void clearEntity() {
entity = null;
}
public ModelPartData getPartData(String type){
return parts.get(type);
}
enableRotation = compound.getBoolean("EnableRotation");
if (enableRotation)
rotation.readFromNBT(compound.getCompoundTag("ModelRotation"));
public void removePart(String type) {
parts.remove(type);
}
breasts = compound.getByte("Breasts");
extra = compound.getCompoundTag("ExtraData");
public ModelPartData getOrCreatePart(String type) {
ModelPartData part = parts.get(type);
if(part == null)
parts.put(type, part = new ModelPartData());
return part;
}
public float getBodyY(){
if(legParts.type == 3)
return (0.9f - modelScale.body.scaleY) * 0.75f + getLegsY();
if(legParts.type == 3)
return (0.5f - modelScale.body.scaleY) * 0.75f + getLegsY();
return (1 - modelScale.body.scaleY) * 0.75f + getLegsY();
}
HashMap<String, ModelPartData> parts = new HashMap<String, ModelPartData>();
NBTTagList list = compound.getTagList("Parts", 10);
for (int i = 0; i < list.tagCount(); i++) {
NBTTagCompound item = list.getCompoundTagAt(i);
ModelPartData part = new ModelPartData();
part.readFromNBT(item);
parts.put(item.getString("PartName"), part);
}
this.parts = parts;
public float getLegsY() {
if(legParts.type == 3)
return (0.87f - modelScale.legs.scaleY);
return (1 - modelScale.legs.scaleY) * 0.75f;
}
}
//0 - hidden, 1 - 2d, 2 - 3d
public void headWear(byte config) {
headwear = ValueUtil.clamp(config, (byte)0, (byte)2);
}
public void setEntityClass(Class<? extends EntityLivingBase> entityClass) {
this.entityClass = entityClass;
entity = null;
extra = new NBTTagCompound();
if (entityClass == EntityHorse.class)
extra.setInteger("Type", -1);
}
public byte headWear() {
return this.headwear;
}
public Class<? extends EntityLivingBase> getEntityClass() {
return entityClass;
}
//0 - hidden, 1 - 2d, 2 - 3d
public void bodyWear(byte config) {
bodywear = ValueUtil.clamp(config, (byte)0, (byte)2);
}
public float offsetY() {
if (entity == null)
return -getBodyY();
return entity.height - 1.8f;
}
public byte bodyWear() {
return this.bodywear;
}
public void clearEntity() {
entity = null;
}
//0 - hidden, 1 - 2d, 2 - 3d
public void rightArmWear(byte config) {
config = ValueUtil.clamp(config, (byte)0, (byte)2);
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (armwear == 0)
armwear = 2;
else if (armwear == 3)
armwear = 1;
} else {
if (armwear == 1)
armwear = 3;
else if (armwear == 2)
armwear = 0;
}
public ModelPartData getPartData(String type) {
return parts.get(type);
}
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidArmwear = 0;
} else if (config == 2) {
if (solidArmwear == 0) {
solidArmwear = 2;
} else if (solidArmwear == 3) {
solidArmwear = 1;
}
}
}
public void removePart(String type) {
parts.remove(type);
}
public byte rightArmWear() {
if (armwear == 0 || armwear == 3) {
return 0;
} else if (solidArmwear == 1 || solidArmwear == 2) {
return 2;
} else {
return 1;
}
}
public ModelPartData getOrCreatePart(String type) {
ModelPartData part = parts.get(type);
if (part == null)
parts.put(type, part = new ModelPartData());
return part;
}
//0 - hidden, 1 - 2d, 2 - 3d
public void leftArmWear(byte config) {
config = ValueUtil.clamp(config, (byte)0, (byte)2);
public float getBodyY() {
if (legParts.type == 3)
return (0.9f - modelScale.body.scaleY) * 0.75f + getLegsY();
if (legParts.type == 3)
return (0.5f - modelScale.body.scaleY) * 0.75f + getLegsY();
return (1 - modelScale.body.scaleY) * 0.75f + getLegsY();
}
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (armwear == 0)
armwear = 3;
else if (armwear == 2)
armwear = 1;
} else {
if (armwear == 1)
armwear = 2;
else if (armwear == 3)
armwear = 0;
}
public float getLegsY() {
if (legParts.type == 3)
return (0.87f - modelScale.legs.scaleY);
return (1 - modelScale.legs.scaleY) * 0.75f;
}
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidArmwear = 0;
} else if (config == 2) {
if (solidArmwear == 0) {
solidArmwear = 3;
} else if (solidArmwear == 2) {
solidArmwear = 1;
}
}
}
//0 - hidden, 1 - 2d, 2 - 3d
public void headWear(byte config) {
headwear = ValueUtil.clamp(config, (byte) 0, (byte) 2);
}
public byte leftArmWear() {
if (armwear == 0 || armwear == 2) {
return 0;
} else if (solidArmwear == 1 || solidArmwear == 3) {
return 2;
} else {
return 1;
}
}
public byte headWear() {
return this.headwear;
}
public void rightLegWear(byte config) {
config = ValueUtil.clamp(config, (byte)0, (byte)2);
//0 - hidden, 1 - 2d, 2 - 3d
public void bodyWear(byte config) {
bodywear = ValueUtil.clamp(config, (byte) 0, (byte) 2);
}
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (legwear == 0)
legwear = 2;
else if (legwear == 3)
legwear = 1;
} else {
if (legwear == 1)
legwear = 3;
else if (legwear == 2)
legwear = 0;
}
public byte bodyWear() {
return this.bodywear;
}
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidLegwear = 0;
} else if (config == 2) {
if (solidLegwear == 0) {
solidLegwear = 2;
} else if (solidLegwear == 3) {
solidLegwear = 1;
}
}
}
//0 - hidden, 1 - 2d, 2 - 3d
public void rightArmWear(byte config) {
config = ValueUtil.clamp(config, (byte) 0, (byte) 2);
public byte rightLegWear() {
if (legwear == 0 || legwear == 3) {
return 0;
} else if (solidLegwear == 1 || solidLegwear == 2) {
return 2;
} else {
return 1;
}
}
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (armwear == 0)
armwear = 2;
else if (armwear == 3)
armwear = 1;
} else {
if (armwear == 1)
armwear = 3;
else if (armwear == 2)
armwear = 0;
}
public void leftLegWear(byte config) {
config = ValueUtil.clamp(config, (byte)0, (byte)2);
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidArmwear = 0;
} else if (config == 2) {
if (solidArmwear == 0) {
solidArmwear = 2;
} else if (solidArmwear == 3) {
solidArmwear = 1;
}
}
}
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (legwear == 0)
legwear = 3;
else if (legwear == 2)
legwear = 1;
} else {
if (legwear == 1)
legwear = 2;
else if (legwear == 3)
legwear = 0;
}
public byte rightArmWear() {
if (armwear == 0 || armwear == 3) {
return 0;
} else if (solidArmwear == 1 || solidArmwear == 2) {
return 2;
} else {
return 1;
}
}
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidLegwear = 0;
} else if (config == 2) {
if (solidLegwear == 0) {
solidLegwear = 3;
} else if (solidLegwear == 2) {
solidLegwear = 1;
}
}
}
//0 - hidden, 1 - 2d, 2 - 3d
public void leftArmWear(byte config) {
config = ValueUtil.clamp(config, (byte) 0, (byte) 2);
public byte leftLegWear() {
if (legwear == 0 || legwear == 2) {
return 0;
} else if (solidLegwear == 1 || solidLegwear == 3) {
return 2;
} else {
return 1;
}
}
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (armwear == 0)
armwear = 3;
else if (armwear == 2)
armwear = 1;
} else {
if (armwear == 1)
armwear = 2;
else if (armwear == 3)
armwear = 0;
}
public void hidePart(int part, byte hide) {
part = ValueUtil.clamp(part,0,3);
hide = part > 1 ? ValueUtil.clamp(hide,(byte) 0,(byte) 3) : ValueUtil.clamp(hide,(byte) 0,(byte) 1);
switch (part) {
case 0:
this.hideHead = hide;
break;
case 1:
this.hideBody = hide;
break;
case 2:
this.hideArms = hide;
break;
case 3:
this.hideLegs = hide;
break;
}
}
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidArmwear = 0;
} else if (config == 2) {
if (solidArmwear == 0) {
solidArmwear = 3;
} else if (solidArmwear == 2) {
solidArmwear = 1;
}
}
}
public int hidden(int part) {
part = ValueUtil.clamp(part,0,3);
switch (part) {
case 0:
return this.hideHead;
case 1:
return this.hideBody;
case 2:
return this.hideArms;
case 3:
return this.hideLegs;
}
return 0;
}
public byte leftArmWear() {
if (armwear == 0 || armwear == 2) {
return 0;
} else if (solidArmwear == 1 || solidArmwear == 3) {
return 2;
} else {
return 1;
}
}
public void enableRotation(boolean enableRotation) {
this.enableRotation = enableRotation;
}
public void rightLegWear(byte config) {
config = ValueUtil.clamp(config, (byte) 0, (byte) 2);
public boolean enableRotation() {
return this.enableRotation;
}
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (legwear == 0)
legwear = 2;
else if (legwear == 3)
legwear = 1;
} else {
if (legwear == 1)
legwear = 3;
else if (legwear == 2)
legwear = 0;
}
public IModelRotate getRotation() {
return this.rotation;
}
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidLegwear = 0;
} else if (config == 2) {
if (solidLegwear == 0) {
solidLegwear = 2;
} else if (solidLegwear == 3) {
solidLegwear = 1;
}
}
}
public IModelScale getScale() {
return this.modelScale;
}
public byte rightLegWear() {
if (legwear == 0 || legwear == 3) {
return 0;
} else if (solidLegwear == 1 || solidLegwear == 2) {
return 2;
} else {
return 1;
}
}
public void setEntity(String string) {
entityClass = null;
entity = null;
try {
Class<?> cls = Class.forName(string);
if (EntityLivingBase.class.isAssignableFrom(cls))
entityClass = cls.asSubclass(EntityLivingBase.class);
public void leftLegWear(byte config) {
config = ValueUtil.clamp(config, (byte) 0, (byte) 2);
} catch (ClassNotFoundException ignored) {}
}
// Hide Arm/Legwear [0: None, 1: Both, 2: Right, 3: Left],
if (config == 1 || config == 2) {
if (legwear == 0)
legwear = 3;
else if (legwear == 2)
legwear = 1;
} else {
if (legwear == 1)
legwear = 2;
else if (legwear == 3)
legwear = 0;
}
public String getEntity() {
return entityClass == null ? null : entityClass.getName();
}
// Solid or normal arm/legwear [0: None, 1: Both, 2: Right, 3: Left]
if (config == 1) {
solidLegwear = 0;
} else if (config == 2) {
if (solidLegwear == 0) {
solidLegwear = 3;
} else if (solidLegwear == 2) {
solidLegwear = 1;
}
}
}
public byte leftLegWear() {
if (legwear == 0 || legwear == 2) {
return 0;
} else if (solidLegwear == 1 || solidLegwear == 3) {
return 2;
} else {
return 1;
}
}
public void hidePart(int part, byte hide) {
part = ValueUtil.clamp(part, 0, 3);
hide = part > 1 ? ValueUtil.clamp(hide, (byte) 0, (byte) 3) : ValueUtil.clamp(hide, (byte) 0, (byte) 1);
switch (part) {
case 0:
this.hideHead = hide;
break;
case 1:
this.hideBody = hide;
break;
case 2:
this.hideArms = hide;
break;
case 3:
this.hideLegs = hide;
break;
}
}
public int hidden(int part) {
part = ValueUtil.clamp(part, 0, 3);
switch (part) {
case 0:
return this.hideHead;
case 1:
return this.hideBody;
case 2:
return this.hideArms;
case 3:
return this.hideLegs;
}
return 0;
}
public void enableRotation(boolean enableRotation) {
this.enableRotation = enableRotation;
}
public boolean enableRotation() {
return this.enableRotation;
}
public IModelRotate getRotation() {
return this.rotation;
}
public IModelScale getScale() {
return this.modelScale;
}
public void setEntity(String string) {
entityClass = null;
entity = null;
try {
Class<?> cls = Class.forName(string);
if (EntityLivingBase.class.isAssignableFrom(cls))
entityClass = cls.asSubclass(EntityLivingBase.class);
} catch (ClassNotFoundException ignored) {
}
}
public String getEntity() {
return entityClass == null ? null : entityClass.getName();
}
}
@@ -4,76 +4,75 @@ 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 int color = 0xFFFFFF;
public String texture;
public byte type = 0;
public byte pattern = 0;
public boolean playerTexture;
public boolean playerTexture;
private ResourceLocation location;
private ResourceLocation location;
public ModelPartData(){
playerTexture = true;
}
public ModelPartData() {
playerTexture = true;
}
public ModelPartData(String texture) {
this.texture = texture;
playerTexture = false;
}
public ModelPartData(String texture) {
this.texture = texture;
playerTexture = false;
}
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Type", type);
compound.setInteger("Color", color);
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setByte("Type", type);
compound.setInteger("Color", color);
compound.setByte("Pattern", pattern);
if(texture != null && !texture.isEmpty()) {
compound.setString("Texture", texture);
}
compound.setBoolean("PlayerTexture", playerTexture);
return compound;
}
if (texture != null && !texture.isEmpty()) {
compound.setString("Texture", texture);
}
compound.setBoolean("PlayerTexture", playerTexture);
return compound;
}
public void readFromNBT(NBTTagCompound compound){
type = compound.getByte("Type");
color = compound.getInteger("Color");
texture = compound.getString("Texture");
public void readFromNBT(NBTTagCompound compound) {
type = compound.getByte("Type");
color = compound.getInteger("Color");
texture = compound.getString("Texture");
pattern = compound.getByte("Pattern");
playerTexture = compound.getBoolean("PlayerTexture");
location = null;
}
playerTexture = compound.getBoolean("PlayerTexture");
location = null;
}
public ResourceLocation getResource(){
if(texture.isEmpty())
return null;
if(location != null)
return location;
location = new ResourceLocation(texture);
return location;
}
public ResourceLocation getResource() {
if (texture.isEmpty())
return null;
if (location != null)
return location;
location = new ResourceLocation(texture);
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{
this.texture = "customnpcs:textures/parts/"+ texture + ".png";
playerTexture = false;
}
}
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;
}
}
public String toString(){
return "Color: " + color + " Type: " + type;
}
public String toString() {
return "Color: " + color + " Type: " + type;
}
public String getColor() {
String str = Integer.toHexString(color);
public String getColor() {
String str = Integer.toHexString(color);
while(str.length() < 6)
str = "0" + str;
while (str.length() < 6)
str = "0" + str;
return str;
}
return str;
}
}
@@ -6,83 +6,83 @@ import noppes.npcs.api.entity.data.IModelRotatePart;
import noppes.npcs.util.ValueUtil;
public class ModelRotate implements IModelRotate {
// Rotation
public boolean whileStanding = true;
public boolean whileAttacking = false;
public boolean whileMoving = false;
// Rotation
public boolean whileStanding = true;
public boolean whileAttacking = false;
public boolean whileMoving = false;
public ModelRotatePart head = new ModelRotatePart();
public ModelRotatePart body = new ModelRotatePart();
public ModelRotatePart larm = new ModelRotatePart();
public ModelRotatePart rarm = new ModelRotatePart();
public ModelRotatePart lleg = new ModelRotatePart();
public ModelRotatePart rleg = new ModelRotatePart();
public ModelRotatePart head = new ModelRotatePart();
public ModelRotatePart body = new ModelRotatePart();
public ModelRotatePart larm = new ModelRotatePart();
public ModelRotatePart rarm = new ModelRotatePart();
public ModelRotatePart lleg = new ModelRotatePart();
public ModelRotatePart rleg = new ModelRotatePart();
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("PuppetStanding", whileStanding);
compound.setBoolean("PuppetAttacking", whileAttacking);
compound.setBoolean("PuppetMoving", whileMoving);
compound.setTag("PuppetHead", head.writeToNBT());
compound.setTag("PuppetBody", body.writeToNBT());
compound.setTag("PuppetRArm", rarm.writeToNBT());
compound.setTag("PuppetLArm", larm.writeToNBT());
compound.setTag("PuppetRLeg", rleg.writeToNBT());
compound.setTag("PuppetLLeg", lleg.writeToNBT());
return compound;
}
public void readFromNBT(NBTTagCompound compound){
whileStanding = compound.getBoolean("PuppetStanding");
whileAttacking = compound.getBoolean("PuppetAttacking");
whileMoving = compound.getBoolean("PuppetMoving");
head.readFromNBT(compound.getCompoundTag("PuppetHead"));
body.readFromNBT(compound.getCompoundTag("PuppetBody"));
rarm.readFromNBT(compound.getCompoundTag("PuppetRArm"));
larm.readFromNBT(compound.getCompoundTag("PuppetLArm"));
rleg.readFromNBT(compound.getCompoundTag("PuppetRLeg"));
lleg.readFromNBT(compound.getCompoundTag("PuppetLLeg"));
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("PuppetStanding", whileStanding);
compound.setBoolean("PuppetAttacking", whileAttacking);
compound.setBoolean("PuppetMoving", whileMoving);
compound.setTag("PuppetHead", head.writeToNBT());
compound.setTag("PuppetBody", body.writeToNBT());
compound.setTag("PuppetRArm", rarm.writeToNBT());
compound.setTag("PuppetLArm", larm.writeToNBT());
compound.setTag("PuppetRLeg", rleg.writeToNBT());
compound.setTag("PuppetLLeg", lleg.writeToNBT());
return compound;
}
public boolean whileStanding() {
return this.whileStanding;
}
public void readFromNBT(NBTTagCompound compound) {
whileStanding = compound.getBoolean("PuppetStanding");
whileAttacking = compound.getBoolean("PuppetAttacking");
whileMoving = compound.getBoolean("PuppetMoving");
head.readFromNBT(compound.getCompoundTag("PuppetHead"));
body.readFromNBT(compound.getCompoundTag("PuppetBody"));
rarm.readFromNBT(compound.getCompoundTag("PuppetRArm"));
larm.readFromNBT(compound.getCompoundTag("PuppetLArm"));
rleg.readFromNBT(compound.getCompoundTag("PuppetRLeg"));
lleg.readFromNBT(compound.getCompoundTag("PuppetLLeg"));
}
public void whileStanding(boolean whileStanding) {
this.whileStanding = whileStanding;
}
public boolean whileStanding() {
return this.whileStanding;
}
public boolean whileAttacking() {
return this.whileAttacking;
}
public void whileStanding(boolean whileStanding) {
this.whileStanding = whileStanding;
}
public void whileAttacking(boolean whileAttacking) {
this.whileAttacking = whileAttacking;
}
public boolean whileAttacking() {
return this.whileAttacking;
}
public boolean whileMoving() {
return this.whileMoving;
}
public void whileAttacking(boolean whileAttacking) {
this.whileAttacking = whileAttacking;
}
public void whileMoving(boolean whileMoving) {
this.whileMoving = whileMoving;
}
public boolean whileMoving() {
return this.whileMoving;
}
public IModelRotatePart getPart(int part) {
switch (ValueUtil.clamp(part,0,5)) {
case 0:
return head;
case 1:
return body;
case 2:
return larm;
case 3:
return rarm;
case 4:
return lleg;
case 5:
return rleg;
}
return null;
}
public void whileMoving(boolean whileMoving) {
this.whileMoving = whileMoving;
}
public IModelRotatePart getPart(int part) {
switch (ValueUtil.clamp(part, 0, 5)) {
case 0:
return head;
case 1:
return body;
case 2:
return larm;
case 3:
return rarm;
case 4:
return lleg;
case 5:
return rleg;
}
return null;
}
}
@@ -5,48 +5,48 @@ import noppes.npcs.api.entity.data.IModelRotatePart;
import noppes.npcs.util.ValueUtil;
public class ModelRotatePart implements IModelRotatePart {
public float rotationX = 0f, rotationY = 0f, rotationZ = 0f;
public boolean disabled = false;
public float rotationX = 0f, rotationY = 0f, rotationZ = 0f;
public boolean disabled = false;
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("Disabled", disabled);
compound.setFloat("RotationX", rotationX);
compound.setFloat("RotationY", rotationY);
compound.setFloat("RotationZ", rotationZ);
return compound;
}
public void readFromNBT(NBTTagCompound compound){
disabled = compound.getBoolean("Disabled");
rotationX = ValueUtil.clamp(compound.getFloat("RotationX"), -0.5f, 0.5f);
rotationY = ValueUtil.clamp(compound.getFloat("RotationY"), -0.5f, 0.5f);
rotationZ = ValueUtil.clamp(compound.getFloat("RotationZ"), -0.5f, 0.5f);
}
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setBoolean("Disabled", disabled);
compound.setFloat("RotationX", rotationX);
compound.setFloat("RotationY", rotationY);
compound.setFloat("RotationZ", rotationZ);
return compound;
}
public void setRotation(float x, float y, float z) {
this.rotationX = ValueUtil.clamp(x, -0.5f, 0.5f);
this.rotationY = ValueUtil.clamp(y, -0.5f, 0.5f);
this.rotationZ = ValueUtil.clamp(z, -0.5f, 0.5f);
}
public void readFromNBT(NBTTagCompound compound) {
disabled = compound.getBoolean("Disabled");
rotationX = ValueUtil.clamp(compound.getFloat("RotationX"), -0.5f, 0.5f);
rotationY = ValueUtil.clamp(compound.getFloat("RotationY"), -0.5f, 0.5f);
rotationZ = ValueUtil.clamp(compound.getFloat("RotationZ"), -0.5f, 0.5f);
}
public float getRotateX() {
return this.rotationX;
}
public void setRotation(float x, float y, float z) {
this.rotationX = ValueUtil.clamp(x, -0.5f, 0.5f);
this.rotationY = ValueUtil.clamp(y, -0.5f, 0.5f);
this.rotationZ = ValueUtil.clamp(z, -0.5f, 0.5f);
}
public float getRotateY() {
return this.rotationY;
}
public float getRotateX() {
return this.rotationX;
}
public float getRotateZ() {
return this.rotationZ;
}
public float getRotateY() {
return this.rotationY;
}
public void disabled(boolean disabled) {
this.disabled = disabled;
}
public float getRotateZ() {
return this.rotationZ;
}
public boolean disabled() {
return this.disabled;
}
public void disabled(boolean disabled) {
this.disabled = disabled;
}
public boolean disabled() {
return this.disabled;
}
}
@@ -28,7 +28,7 @@ public class ModelScale implements IModelScale {
@Override
public IModelScalePart getPart(int part) {
switch (ValueUtil.clamp(part,0,3)) {
switch (ValueUtil.clamp(part, 0, 3)) {
case 0:
return head;
case 1:
@@ -5,47 +5,47 @@ import noppes.npcs.api.entity.data.IModelScalePart;
import noppes.npcs.util.ValueUtil;
public class ModelScalePart implements IModelScalePart {
public float scaleX = 1, scaleY = 1, scaleZ = 1;
public float scaleX = 1, scaleY = 1, scaleZ = 1;
public NBTTagCompound writeToNBT(){
NBTTagCompound compound = new NBTTagCompound();
compound.setFloat("ScaleX", scaleX);
compound.setFloat("ScaleY", scaleY);
compound.setFloat("ScaleZ", scaleZ);
public NBTTagCompound writeToNBT() {
NBTTagCompound compound = new NBTTagCompound();
compound.setFloat("ScaleX", scaleX);
compound.setFloat("ScaleY", scaleY);
compound.setFloat("ScaleZ", scaleZ);
return compound;
}
public void readFromNBT(NBTTagCompound compound){
scaleX = ValueUtil.clamp(compound.getFloat("ScaleX"), 0.5f, 1.5f);
scaleY = ValueUtil.clamp(compound.getFloat("ScaleY"), 0.5f, 1.5f);
scaleZ = ValueUtil.clamp(compound.getFloat("ScaleZ"), 0.5f, 1.5f);
}
public String toString(){
return "ScaleX: " + scaleX + " - ScaleY: " + scaleY + " - ScaleZ: " + scaleZ;
}
return compound;
}
public void setScale(float x, float y) {
scaleZ = scaleX = x;
scaleY = y;
}
public void readFromNBT(NBTTagCompound compound) {
scaleX = ValueUtil.clamp(compound.getFloat("ScaleX"), 0.5f, 1.5f);
scaleY = ValueUtil.clamp(compound.getFloat("ScaleY"), 0.5f, 1.5f);
scaleZ = ValueUtil.clamp(compound.getFloat("ScaleZ"), 0.5f, 1.5f);
}
public void setScale(float x, float y, float z) {
scaleX = ValueUtil.clamp(x, 0.5f, 1.5f);
scaleY = ValueUtil.clamp(y, 0.5f, 1.5f);
scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f);
}
public String toString() {
return "ScaleX: " + scaleX + " - ScaleY: " + scaleY + " - ScaleZ: " + scaleZ;
}
public float getScaleX() {
return scaleX;
}
public void setScale(float x, float y) {
scaleZ = scaleX = x;
scaleY = y;
}
public float getScaleY() {
return scaleY;
}
public void setScale(float x, float y, float z) {
scaleX = ValueUtil.clamp(x, 0.5f, 1.5f);
scaleY = ValueUtil.clamp(y, 0.5f, 1.5f);
scaleZ = ValueUtil.clamp(z, 0.5f, 1.5f);
}
public float getScaleZ() {
return scaleZ;
}
public float getScaleX() {
return scaleX;
}
public float getScaleY() {
return scaleY;
}
public float getScaleZ() {
return scaleZ;
}
}