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-27 04:38:51 +01:00
|
|
|
import org.bukkit.entity.EntityType;
|
|
|
|
|
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
|
|
|
|
2013-11-27 04:38:51 +01:00
|
|
|
private static HashMap<Enum, DisguiseValues> values = new HashMap<Enum, DisguiseValues>();
|
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:
|
|
|
|
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-27 04:38:51 +01:00
|
|
|
public static DisguiseValues getEntityValues(EntityType type) {
|
|
|
|
return values.get(type);
|
|
|
|
}
|
|
|
|
|
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-11-18 04:24:25 +01:00
|
|
|
private int enumEntitySize;
|
2013-07-15 09:33:23 +02:00
|
|
|
private HashMap<Integer, Object> metaValues = new HashMap<Integer, Object>();
|
2013-11-22 21:19:30 +01:00
|
|
|
private Class nmsEntityClass;
|
2013-07-15 09:33:23 +02:00
|
|
|
|
2013-11-27 04:38:51 +01:00
|
|
|
public DisguiseValues(Enum type, Class classType, int entitySize) {
|
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;
|
2013-07-15 09:33:23 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
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-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
|
|
|
}
|
|
|
|
}
|