2013-11-22 21:10:20 +01:00
|
|
|
package me.libraryaddict.disguise.utilities;
|
2013-07-11 20:36:55 +02:00
|
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
2013-11-22 21:10:20 +01:00
|
|
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
2013-07-11 20:36:55 +02:00
|
|
|
|
2013-11-22 21:10:20 +01:00
|
|
|
public class DisguiseValues {
|
2013-07-12 22:19:24 +02:00
|
|
|
|
2015-05-30 15:34:38 +02:00
|
|
|
private static HashMap<DisguiseType, DisguiseValues> values = new HashMap<>();
|
2013-11-22 21:10:20 +01:00
|
|
|
|
|
|
|
public static DisguiseValues getDisguiseValues(DisguiseType type) {
|
2013-07-28 02:05:47 +02:00
|
|
|
switch (type) {
|
|
|
|
case DONKEY:
|
|
|
|
case MULE:
|
|
|
|
case UNDEAD_HORSE:
|
|
|
|
case SKELETON_HORSE:
|
2013-07-11 20:36:55 +02:00
|
|
|
type = DisguiseType.HORSE;
|
2013-07-28 02:05:47 +02:00
|
|
|
break;
|
|
|
|
case MINECART_CHEST:
|
2014-06-18 23:26:54 +02:00
|
|
|
case MINECART_COMMAND:
|
2013-07-28 02:05:47 +02:00
|
|
|
case MINECART_FURNACE:
|
|
|
|
case MINECART_HOPPER:
|
|
|
|
case MINECART_TNT:
|
|
|
|
case MINECART_MOB_SPAWNER:
|
2013-07-16 13:42:35 +02:00
|
|
|
type = DisguiseType.MINECART;
|
2013-07-28 02:05:47 +02:00
|
|
|
break;
|
|
|
|
case WITHER_SKELETON:
|
2013-07-11 20:36:55 +02:00
|
|
|
type = DisguiseType.SKELETON;
|
2013-07-28 02:05:47 +02:00
|
|
|
break;
|
|
|
|
case ZOMBIE_VILLAGER:
|
2013-07-16 13:42:35 +02:00
|
|
|
type = DisguiseType.ZOMBIE;
|
2013-07-28 02:05:47 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2013-07-15 09:33:23 +02:00
|
|
|
return values.get(type);
|
2013-07-11 20:38:38 +02:00
|
|
|
}
|
|
|
|
|
2013-11-22 21:19:30 +01:00
|
|
|
public static HashMap<Integer, Object> getMetaValues(DisguiseType type) {
|
|
|
|
return getDisguiseValues(type).getMetaValues();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Class getNmsEntityClass(DisguiseType type) {
|
|
|
|
return getDisguiseValues(type).getNmsEntityClass();
|
|
|
|
}
|
|
|
|
|
2013-12-22 01:03:47 +01:00
|
|
|
private FakeBoundingBox adultBox;
|
|
|
|
private FakeBoundingBox babyBox;
|
2013-12-22 05:35:57 +01:00
|
|
|
private float[] entitySize;
|
2013-11-18 04:24:25 +01:00
|
|
|
private int enumEntitySize;
|
2014-05-23 04:52:21 +02:00
|
|
|
private double maxHealth;
|
2015-05-30 15:34:38 +02:00
|
|
|
private HashMap<Integer, Object> metaValues = new HashMap<>();
|
2013-11-22 21:19:30 +01:00
|
|
|
private Class nmsEntityClass;
|
2013-07-15 09:33:23 +02:00
|
|
|
|
2015-07-07 17:30:12 +02:00
|
|
|
@SuppressWarnings("LeakingThisInConstructor")
|
2014-05-23 04:52:21 +02:00
|
|
|
public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth) {
|
2013-07-15 09:33:23 +02:00
|
|
|
values.put(type, this);
|
2013-08-05 07:26:56 +02:00
|
|
|
enumEntitySize = entitySize;
|
2013-11-22 21:10:20 +01:00
|
|
|
nmsEntityClass = classType;
|
2014-05-23 04:52:21 +02:00
|
|
|
this.maxHealth = maxHealth;
|
2013-07-15 09:33:23 +02:00
|
|
|
}
|
2013-07-16 07:23:11 +02:00
|
|
|
|
2013-12-22 00:36:06 +01:00
|
|
|
public FakeBoundingBox getAdultBox() {
|
|
|
|
return adultBox;
|
|
|
|
}
|
|
|
|
|
2013-12-22 01:03:47 +01:00
|
|
|
public FakeBoundingBox getBabyBox() {
|
|
|
|
return babyBox;
|
|
|
|
}
|
|
|
|
|
2013-12-22 05:35:57 +01:00
|
|
|
public float[] getEntitySize() {
|
|
|
|
return entitySize;
|
|
|
|
}
|
|
|
|
|
2013-11-18 04:24:25 +01:00
|
|
|
public int getEntitySize(double paramDouble) {
|
|
|
|
double d = paramDouble - (((int) Math.floor(paramDouble)) + 0.5D);
|
|
|
|
|
|
|
|
switch (enumEntitySize) {
|
|
|
|
case 1:
|
|
|
|
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
|
|
|
|
return (int) Math.ceil(paramDouble * 32.0D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) Math.floor(paramDouble * 32.0D);
|
|
|
|
case 2:
|
|
|
|
if (d < 0.0D ? d < -0.3125D : d < 0.3125D) {
|
|
|
|
return (int) Math.floor(paramDouble * 32.0D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) Math.ceil(paramDouble * 32.0D);
|
|
|
|
case 3:
|
|
|
|
if (d > 0.0D) {
|
|
|
|
return (int) Math.floor(paramDouble * 32.0D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) Math.ceil(paramDouble * 32.0D);
|
|
|
|
case 4:
|
|
|
|
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
|
|
|
|
return (int) Math.ceil(paramDouble * 32.0D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) Math.floor(paramDouble * 32.0D);
|
|
|
|
case 5:
|
|
|
|
if (d < 0.0D ? d < -0.1875D : d < 0.1875D) {
|
|
|
|
return (int) Math.floor(paramDouble * 32.0D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) Math.ceil(paramDouble * 32.0D);
|
2013-12-05 08:15:58 +01:00
|
|
|
default:
|
|
|
|
break;
|
2013-11-18 04:24:25 +01:00
|
|
|
}
|
|
|
|
if (d > 0.0D) {
|
|
|
|
return (int) Math.ceil(paramDouble * 32.0D);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (int) Math.floor(paramDouble * 32.0D);
|
2013-08-08 23:14:44 +02:00
|
|
|
}
|
|
|
|
|
2014-05-23 04:52:21 +02:00
|
|
|
public double getMaxHealth() {
|
|
|
|
return maxHealth;
|
|
|
|
}
|
|
|
|
|
2013-07-15 09:33:23 +02:00
|
|
|
public HashMap<Integer, Object> getMetaValues() {
|
|
|
|
return metaValues;
|
2013-07-11 20:38:38 +02:00
|
|
|
}
|
|
|
|
|
2013-11-22 21:19:30 +01:00
|
|
|
public Class getNmsEntityClass() {
|
|
|
|
return nmsEntityClass;
|
|
|
|
}
|
|
|
|
|
2013-12-22 01:03:47 +01:00
|
|
|
public void setAdultBox(FakeBoundingBox newBox) {
|
|
|
|
adultBox = newBox;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setBabyBox(FakeBoundingBox newBox) {
|
|
|
|
babyBox = newBox;
|
|
|
|
}
|
|
|
|
|
2013-12-22 05:35:57 +01:00
|
|
|
public void setEntitySize(float[] size) {
|
|
|
|
this.entitySize = size;
|
|
|
|
}
|
|
|
|
|
2013-07-11 20:38:38 +02:00
|
|
|
public void setMetaValue(int no, Object value) {
|
2013-07-15 09:33:23 +02:00
|
|
|
metaValues.put(no, value);
|
2013-07-11 20:36:55 +02:00
|
|
|
}
|
|
|
|
}
|