LibsDisguises/src/me/libraryaddict/disguise/utilities/DisguiseValues.java

117 lines
3.3 KiB
Java
Raw Normal View History

package me.libraryaddict.disguise.utilities;
2013-07-11 20:36:55 +02:00
import java.util.HashMap;
import org.bukkit.entity.EntityType;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
2013-07-11 20:36:55 +02:00
public class DisguiseValues {
private static HashMap<Enum, DisguiseValues> values = new HashMap<Enum, DisguiseValues>();
public static DisguiseValues getDisguiseValues(DisguiseType type) {
switch (type) {
case DONKEY:
case MULE:
case UNDEAD_HORSE:
case SKELETON_HORSE:
2013-07-11 20:36:55 +02:00
type = DisguiseType.HORSE;
break;
case MINECART_CHEST:
case MINECART_FURNACE:
case MINECART_HOPPER:
case MINECART_TNT:
case MINECART_MOB_SPAWNER:
type = DisguiseType.MINECART;
break;
case WITHER_SKELETON:
2013-07-11 20:36:55 +02:00
type = DisguiseType.SKELETON;
break;
case ZOMBIE_VILLAGER:
type = DisguiseType.ZOMBIE;
break;
default:
break;
}
return values.get(type);
2013-07-11 20:38:38 +02:00
}
public static DisguiseValues getEntityValues(EntityType type) {
return values.get(type);
}
public static HashMap<Integer, Object> getMetaValues(DisguiseType type) {
return getDisguiseValues(type).getMetaValues();
}
public static Class getNmsEntityClass(DisguiseType type) {
return getDisguiseValues(type).getNmsEntityClass();
}
2013-11-18 04:24:25 +01:00
private int enumEntitySize;
private HashMap<Integer, Object> metaValues = new HashMap<Integer, Object>();
private Class nmsEntityClass;
public DisguiseValues(Enum type, Class classType, int entitySize) {
values.put(type, this);
enumEntitySize = entitySize;
nmsEntityClass = classType;
}
2013-07-16 07:23:11 +02:00
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);
case 6:
}
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
}
public HashMap<Integer, Object> getMetaValues() {
return metaValues;
2013-07-11 20:38:38 +02:00
}
public Class getNmsEntityClass() {
return nmsEntityClass;
}
2013-07-11 20:38:38 +02:00
public void setMetaValue(int no, Object value) {
metaValues.put(no, value);
2013-07-11 20:36:55 +02:00
}
}