Advertisement
Guest User

Bukkit NMS (EntityTypes to find their ID)

a guest
Feb 23rd, 2015
810
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.59 KB | None | 0 0
  1. package net.minecraft.server.v1_8_R1;
  2.  
  3. import com.google.common.collect.Lists;
  4. import com.google.common.collect.Maps;
  5. import java.lang.reflect.Constructor;
  6. import java.util.ArrayList;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.Set;
  10. import org.apache.logging.log4j.LogManager;
  11. import org.apache.logging.log4j.Logger;
  12.  
  13. public class EntityTypes
  14. {
  15.   private static final Logger b = ;
  16.   private static final Map c = Maps.newHashMap();
  17.   private static final Map d = Maps.newHashMap();
  18.   private static final Map e = Maps.newHashMap();
  19.   private static final Map f = Maps.newHashMap();
  20.   private static final Map g = Maps.newHashMap();
  21.   public static final Map eggInfo = Maps.newLinkedHashMap();
  22.  
  23.   private static void a(Class paramClass, String paramString, int paramInt)
  24.   {
  25.     if (c.containsKey(paramString)) {
  26.       throw new IllegalArgumentException("ID is already registered: " + paramString);
  27.     }
  28.     if (e.containsKey(Integer.valueOf(paramInt))) {
  29.       throw new IllegalArgumentException("ID is already registered: " + paramInt);
  30.     }
  31.     if (paramInt == 0) {
  32.       throw new IllegalArgumentException("Cannot register to reserved id: " + paramInt);
  33.     }
  34.     if (paramClass == null) {
  35.       throw new IllegalArgumentException("Cannot register null clazz for id: " + paramInt);
  36.     }
  37.     c.put(paramString, paramClass);
  38.     d.put(paramClass, paramString);
  39.     e.put(Integer.valueOf(paramInt), paramClass);
  40.     f.put(paramClass, Integer.valueOf(paramInt));
  41.     g.put(paramString, Integer.valueOf(paramInt));
  42.   }
  43.  
  44.   private static void a(Class paramClass, String paramString, int paramInt1, int paramInt2, int paramInt3)
  45.   {
  46.     a(paramClass, paramString, paramInt1);
  47.    
  48.     eggInfo.put(Integer.valueOf(paramInt1), new MonsterEggInfo(paramInt1, paramInt2, paramInt3));
  49.   }
  50.  
  51.   static
  52.   {
  53.     a(EntityItem.class, "Item", 1);
  54.     a(EntityExperienceOrb.class, "XPOrb", 2);
  55.    
  56.     a(EntityLeash.class, "LeashKnot", 8);
  57.     a(EntityPainting.class, "Painting", 9);
  58.     a(EntityArrow.class, "Arrow", 10);
  59.     a(EntitySnowball.class, "Snowball", 11);
  60.     a(EntityLargeFireball.class, "Fireball", 12);
  61.     a(EntitySmallFireball.class, "SmallFireball", 13);
  62.     a(EntityEnderPearl.class, "ThrownEnderpearl", 14);
  63.     a(EntityEnderSignal.class, "EyeOfEnderSignal", 15);
  64.     a(EntityPotion.class, "ThrownPotion", 16);
  65.     a(EntityThrownExpBottle.class, "ThrownExpBottle", 17);
  66.     a(EntityItemFrame.class, "ItemFrame", 18);
  67.     a(EntityWitherSkull.class, "WitherSkull", 19);
  68.    
  69.     a(EntityTNTPrimed.class, "PrimedTnt", 20);
  70.     a(EntityFallingBlock.class, "FallingSand", 21);
  71.    
  72.     a(EntityFireworks.class, "FireworksRocketEntity", 22);
  73.    
  74.     a(EntityArmorStand.class, "ArmorStand", 30);
  75.    
  76.     a(EntityBoat.class, "Boat", 41);
  77.     a(EntityMinecartRideable.class, EnumMinecartType.RIDEABLE.b(), 42);
  78.     a(EntityMinecartChest.class, EnumMinecartType.CHEST.b(), 43);
  79.     a(EntityMinecartFurnace.class, EnumMinecartType.FURNACE.b(), 44);
  80.     a(EntityMinecartTNT.class, EnumMinecartType.TNT.b(), 45);
  81.     a(EntityMinecartHopper.class, EnumMinecartType.HOPPER.b(), 46);
  82.     a(EntityMinecartMobSpawner.class, EnumMinecartType.SPAWNER.b(), 47);
  83.     a(EntityMinecartCommandBlock.class, EnumMinecartType.COMMAND_BLOCK.b(), 40);
  84.    
  85.     a(EntityInsentient.class, "Mob", 48);
  86.     a(EntityMonster.class, "Monster", 49);
  87.    
  88.     a(EntityCreeper.class, "Creeper", 50, 894731, 0);
  89.     a(EntitySkeleton.class, "Skeleton", 51, 12698049, 4802889);
  90.     a(EntitySpider.class, "Spider", 52, 3419431, 11013646);
  91.     a(EntityGiantZombie.class, "Giant", 53);
  92.     a(EntityZombie.class, "Zombie", 54, 44975, 7969893);
  93.     a(EntitySlime.class, "Slime", 55, 5349438, 8306542);
  94.     a(EntityGhast.class, "Ghast", 56, 16382457, 12369084);
  95.     a(EntityPigZombie.class, "PigZombie", 57, 15373203, 5009705);
  96.     a(EntityEnderman.class, "Enderman", 58, 1447446, 0);
  97.     a(EntityCaveSpider.class, "CaveSpider", 59, 803406, 11013646);
  98.     a(EntitySilverfish.class, "Silverfish", 60, 7237230, 3158064);
  99.     a(EntityBlaze.class, "Blaze", 61, 16167425, 16775294);
  100.     a(EntityMagmaCube.class, "LavaSlime", 62, 3407872, 16579584);
  101.     a(EntityEnderDragon.class, "EnderDragon", 63);
  102.     a(EntityWither.class, "WitherBoss", 64);
  103.     a(EntityBat.class, "Bat", 65, 4996656, 986895);
  104.     a(EntityWitch.class, "Witch", 66, 3407872, 5349438);
  105.     a(EntityEndermite.class, "Endermite", 67, 1447446, 7237230);
  106.     a(EntityGuardian.class, "Guardian", 68, 5931634, 15826224);
  107.    
  108.     a(EntityPig.class, "Pig", 90, 15771042, 14377823);
  109.     a(EntitySheep.class, "Sheep", 91, 15198183, 16758197);
  110.     a(EntityCow.class, "Cow", 92, 4470310, 10592673);
  111.     a(EntityChicken.class, "Chicken", 93, 10592673, 16711680);
  112.     a(EntitySquid.class, "Squid", 94, 2243405, 7375001);
  113.     a(EntityWolf.class, "Wolf", 95, 14144467, 13545366);
  114.     a(EntityMushroomCow.class, "MushroomCow", 96, 10489616, 12040119);
  115.     a(EntitySnowman.class, "SnowMan", 97);
  116.     a(EntityOcelot.class, "Ozelot", 98, 15720061, 5653556);
  117.     a(EntityIronGolem.class, "VillagerGolem", 99);
  118.     a(EntityHorse.class, "EntityHorse", 100, 12623485, 15656192);
  119.     a(EntityRabbit.class, "Rabbit", 101, 10051392, 7555121);
  120.    
  121.     a(EntityVillager.class, "Villager", 120, 5651507, 12422002);
  122.    
  123.     a(EntityEnderCrystal.class, "EnderCrystal", 200);
  124.   }
  125.  
  126.   public static Entity createEntityByName(String paramString, World paramWorld)
  127.   {
  128.     Entity localEntity = null;
  129.     try
  130.     {
  131.       Class localClass = (Class)c.get(paramString);
  132.       if (localClass != null) {
  133.         localEntity = (Entity)localClass.getConstructor(new Class[] { World.class }).newInstance(new Object[] { paramWorld });
  134.       }
  135.     }
  136.     catch (Exception localException)
  137.     {
  138.       localException.printStackTrace();
  139.     }
  140.     return localEntity;
  141.   }
  142.  
  143.   public static Entity a(NBTTagCompound paramNBTTagCompound, World paramWorld)
  144.   {
  145.     Entity localEntity = null;
  146.     if ("Minecart".equals(paramNBTTagCompound.getString("id")))
  147.     {
  148.       paramNBTTagCompound.setString("id", EnumMinecartType.a(paramNBTTagCompound.getInt("Type")).b());
  149.       paramNBTTagCompound.remove("Type");
  150.     }
  151.     try
  152.     {
  153.       Class localClass = (Class)c.get(paramNBTTagCompound.getString("id"));
  154.       if (localClass != null) {
  155.         localEntity = (Entity)localClass.getConstructor(new Class[] { World.class }).newInstance(new Object[] { paramWorld });
  156.       }
  157.     }
  158.     catch (Exception localException)
  159.     {
  160.       localException.printStackTrace();
  161.     }
  162.     if (localEntity != null) {
  163.       localEntity.f(paramNBTTagCompound);
  164.     } else {
  165.       b.warn("Skipping Entity with id " + paramNBTTagCompound.getString("id"));
  166.     }
  167.     return localEntity;
  168.   }
  169.  
  170.   public static Entity a(int paramInt, World paramWorld)
  171.   {
  172.     Entity localEntity = null;
  173.     try
  174.     {
  175.       Class localClass = a(paramInt);
  176.       if (localClass != null) {
  177.         localEntity = (Entity)localClass.getConstructor(new Class[] { World.class }).newInstance(new Object[] { paramWorld });
  178.       }
  179.     }
  180.     catch (Exception localException)
  181.     {
  182.       localException.printStackTrace();
  183.     }
  184.     if (localEntity == null) {
  185.       b.warn("Skipping Entity with id " + paramInt);
  186.     }
  187.     return localEntity;
  188.   }
  189.  
  190.   public static int a(Entity paramEntity)
  191.   {
  192.     Integer localInteger = (Integer)f.get(paramEntity.getClass());
  193.     return localInteger == null ? 0 : localInteger.intValue();
  194.   }
  195.  
  196.   public static Class a(int paramInt)
  197.   {
  198.     return (Class)e.get(Integer.valueOf(paramInt));
  199.   }
  200.  
  201.   public static String b(Entity paramEntity)
  202.   {
  203.     return (String)d.get(paramEntity.getClass());
  204.   }
  205.  
  206.   public static String b(int paramInt)
  207.   {
  208.     return (String)d.get(a(paramInt));
  209.   }
  210.  
  211.   public static List b()
  212.   {
  213.     Set localSet = c.keySet();
  214.     ArrayList localArrayList = Lists.newArrayList();
  215.     for (String str : localSet)
  216.     {
  217.       Class localClass = (Class)c.get(str);
  218.       if ((localClass.getModifiers() & 0x400) != 1024) {
  219.         localArrayList.add(str);
  220.       }
  221.     }
  222.     localArrayList.add("LightningBolt");
  223.     return localArrayList;
  224.   }
  225.  
  226.   public static boolean a(Entity paramEntity, String paramString)
  227.   {
  228.     String str = b(paramEntity);
  229.     if ((str == null) && ((paramEntity instanceof EntityHuman))) {
  230.       str = "Player";
  231.     } else if ((str == null) && ((paramEntity instanceof EntityLightning))) {
  232.       str = "LightningBolt";
  233.     }
  234.     return paramString.equals(str);
  235.   }
  236.  
  237.   public static boolean b(String paramString)
  238.   {
  239.     return ("Player".equals(paramString)) || (b().contains(paramString));
  240.   }
  241.  
  242.   public static void a() {}
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement