Advertisement
Jetp250

NMSUtils - 1.12 version

May 20th, 2017
3,631
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package <your package>;
  2.  
  3. import java.lang.reflect.Field;
  4. import java.util.Iterator;
  5. import java.util.List;
  6.  
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.craftbukkit.v1_12_R1.CraftServer;
  9. import org.bukkit.entity.EntityType;
  10.  
  11. import net.minecraft.server.v1_12_R1.BiomeBase;
  12. import net.minecraft.server.v1_12_R1.BiomeBase.BiomeMeta;
  13. import net.minecraft.server.v1_12_R1.Entity;
  14. import net.minecraft.server.v1_12_R1.EntityAreaEffectCloud;
  15. import net.minecraft.server.v1_12_R1.EntityArmorStand;
  16. import net.minecraft.server.v1_12_R1.EntityArrow;
  17. import net.minecraft.server.v1_12_R1.EntityBat;
  18. import net.minecraft.server.v1_12_R1.EntityBlaze;
  19. import net.minecraft.server.v1_12_R1.EntityBoat;
  20. import net.minecraft.server.v1_12_R1.EntityCaveSpider;
  21. import net.minecraft.server.v1_12_R1.EntityChicken;
  22. import net.minecraft.server.v1_12_R1.EntityCow;
  23. import net.minecraft.server.v1_12_R1.EntityCreeper;
  24. import net.minecraft.server.v1_12_R1.EntityDragonFireball;
  25. import net.minecraft.server.v1_12_R1.EntityEgg;
  26. import net.minecraft.server.v1_12_R1.EntityEnderCrystal;
  27. import net.minecraft.server.v1_12_R1.EntityEnderDragon;
  28. import net.minecraft.server.v1_12_R1.EntityEnderPearl;
  29. import net.minecraft.server.v1_12_R1.EntityEnderSignal;
  30. import net.minecraft.server.v1_12_R1.EntityEnderman;
  31. import net.minecraft.server.v1_12_R1.EntityEndermite;
  32. import net.minecraft.server.v1_12_R1.EntityEvoker;
  33. import net.minecraft.server.v1_12_R1.EntityEvokerFangs;
  34. import net.minecraft.server.v1_12_R1.EntityExperienceOrb;
  35. import net.minecraft.server.v1_12_R1.EntityFallingBlock;
  36. import net.minecraft.server.v1_12_R1.EntityFireball;
  37. import net.minecraft.server.v1_12_R1.EntityFireworks;
  38. import net.minecraft.server.v1_12_R1.EntityGhast;
  39. import net.minecraft.server.v1_12_R1.EntityGiantZombie;
  40. import net.minecraft.server.v1_12_R1.EntityGuardian;
  41. import net.minecraft.server.v1_12_R1.EntityGuardianElder;
  42. import net.minecraft.server.v1_12_R1.EntityHorse;
  43. import net.minecraft.server.v1_12_R1.EntityHorseDonkey;
  44. import net.minecraft.server.v1_12_R1.EntityHorseMule;
  45. import net.minecraft.server.v1_12_R1.EntityHorseSkeleton;
  46. import net.minecraft.server.v1_12_R1.EntityHorseZombie;
  47. import net.minecraft.server.v1_12_R1.EntityIllagerIllusioner;
  48. import net.minecraft.server.v1_12_R1.EntityInsentient;
  49. import net.minecraft.server.v1_12_R1.EntityIronGolem;
  50. import net.minecraft.server.v1_12_R1.EntityItem;
  51. import net.minecraft.server.v1_12_R1.EntityItemFrame;
  52. import net.minecraft.server.v1_12_R1.EntityLeash;
  53. import net.minecraft.server.v1_12_R1.EntityLlama;
  54. import net.minecraft.server.v1_12_R1.EntityLlamaSpit;
  55. import net.minecraft.server.v1_12_R1.EntityMagmaCube;
  56. import net.minecraft.server.v1_12_R1.EntityMinecartChest;
  57. import net.minecraft.server.v1_12_R1.EntityMinecartCommandBlock;
  58. import net.minecraft.server.v1_12_R1.EntityMinecartFurnace;
  59. import net.minecraft.server.v1_12_R1.EntityMinecartHopper;
  60. import net.minecraft.server.v1_12_R1.EntityMinecartMobSpawner;
  61. import net.minecraft.server.v1_12_R1.EntityMinecartRideable;
  62. import net.minecraft.server.v1_12_R1.EntityMinecartTNT;
  63. import net.minecraft.server.v1_12_R1.EntityMushroomCow;
  64. import net.minecraft.server.v1_12_R1.EntityOcelot;
  65. import net.minecraft.server.v1_12_R1.EntityPainting;
  66. import net.minecraft.server.v1_12_R1.EntityParrot;
  67. import net.minecraft.server.v1_12_R1.EntityPig;
  68. import net.minecraft.server.v1_12_R1.EntityPigZombie;
  69. import net.minecraft.server.v1_12_R1.EntityPolarBear;
  70. import net.minecraft.server.v1_12_R1.EntityPotion;
  71. import net.minecraft.server.v1_12_R1.EntityRabbit;
  72. import net.minecraft.server.v1_12_R1.EntitySheep;
  73. import net.minecraft.server.v1_12_R1.EntityShulker;
  74. import net.minecraft.server.v1_12_R1.EntityShulkerBullet;
  75. import net.minecraft.server.v1_12_R1.EntitySilverfish;
  76. import net.minecraft.server.v1_12_R1.EntitySkeleton;
  77. import net.minecraft.server.v1_12_R1.EntitySkeletonStray;
  78. import net.minecraft.server.v1_12_R1.EntitySkeletonWither;
  79. import net.minecraft.server.v1_12_R1.EntitySlime;
  80. import net.minecraft.server.v1_12_R1.EntitySmallFireball;
  81. import net.minecraft.server.v1_12_R1.EntitySnowball;
  82. import net.minecraft.server.v1_12_R1.EntitySnowman;
  83. import net.minecraft.server.v1_12_R1.EntitySpectralArrow;
  84. import net.minecraft.server.v1_12_R1.EntitySpider;
  85. import net.minecraft.server.v1_12_R1.EntitySquid;
  86. import net.minecraft.server.v1_12_R1.EntityTNTPrimed;
  87. import net.minecraft.server.v1_12_R1.EntityThrownExpBottle;
  88. import net.minecraft.server.v1_12_R1.EntityTypes;
  89. import net.minecraft.server.v1_12_R1.EntityVex;
  90. import net.minecraft.server.v1_12_R1.EntityVillager;
  91. import net.minecraft.server.v1_12_R1.EntityVindicator;
  92. import net.minecraft.server.v1_12_R1.EntityWitch;
  93. import net.minecraft.server.v1_12_R1.EntityWither;
  94. import net.minecraft.server.v1_12_R1.EntityWitherSkull;
  95. import net.minecraft.server.v1_12_R1.EntityWolf;
  96. import net.minecraft.server.v1_12_R1.EntityZombie;
  97. import net.minecraft.server.v1_12_R1.EntityZombieHusk;
  98. import net.minecraft.server.v1_12_R1.EntityZombieVillager;
  99. import net.minecraft.server.v1_12_R1.GenericAttributes;
  100. import net.minecraft.server.v1_12_R1.IAttribute;
  101. import net.minecraft.server.v1_12_R1.Item;
  102. import net.minecraft.server.v1_12_R1.MinecraftKey;
  103. import net.minecraft.server.v1_12_R1.MinecraftServer;
  104.  
  105. /**
  106.  * A Free-to-use library class for registering custom entities in Minecraft, using the Spigot server software (ver.
  107.  * 1.12-pre) as its API.
  108.  *
  109.  * @author jetp250
  110.  */
  111. public class NMSUtils {
  112.  
  113.     private static final Field META_LIST_MONSTER;
  114.     private static final Field META_LIST_CREATURE;
  115.     private static final Field META_LIST_WATER_CREATURE;
  116.     private static final Field META_LIST_AMBIENT;
  117.  
  118.     private static final BiomeBase[] BIOMES;
  119.  
  120.     public static final CraftServer CRAFTBUKKIT_SERVER;
  121.     public static final MinecraftServer MINECRAFT_SERVER;
  122.  
  123.     /**
  124.      * Registers an Item (Not an ItemStack!) to be available for use. an ItemStack can then be created using
  125.      * <code>new ItemStack(item)</code>.
  126.      *
  127.      * @param name
  128.      *            - The name of the item, can be anything
  129.      * @param id
  130.      *            - The ID of the item, will be rendered depending on this
  131.      * @param item
  132.      *            - The net.minecraft.server.version.Item itself
  133.      */
  134.     public static void registerItem(String name, int id, Item item) {
  135.         Item.REGISTRY.a(id, new MinecraftKey(name), item);
  136.     }
  137.  
  138.     /**
  139.      * Makes the mob spawn randomly around the world just like vanilla mobs.
  140.      * <p>
  141.      * Unlike the other method, this allows you to choose the 'category' of your mob; Creature, Monster, Ambient or
  142.      * Water Creature - even if it in reality was none of those.
  143.      * <p>
  144.      * If you're using a custom entity class, remember to <b>register</b> it before using this! Otherwise it'll not be
  145.      * rendered by the client.
  146.      * <p>
  147.      * If {@link #isAccessible()} returns false, the process will not be executed.
  148.      *
  149.      * @see #registerEntity(MobType, Class, boolean)
  150.      * @param data
  151.      *            - The spawn data (chance, amount, spawn weight..)
  152.      * @param meta
  153.      *            - The category in which your mob'll spawn (i.e creatures'll spawn in day, monsters during night..)
  154.      * @param biomes
  155.      *            - The array of biomes to let the mobs spawn in, use {@link Biome#COLLECTION_ALL} for all of them.
  156.      */
  157.     public static boolean addRandomSpawn(SpawnData data, MobMeta meta, Biome... biomes) {
  158.         Field field;
  159.         if ((field = meta.getField()) == null) {
  160.             return false;
  161.         }
  162.         try {
  163.             field.setAccessible(true);
  164.             for (Biome biome : biomes) {
  165.                 BiomeBase[] array = biome.getNMSBiomeArray();
  166.                 for (BiomeBase base : array) {
  167.                     @SuppressWarnings("unchecked")
  168.                     List<BiomeMeta> list = (List<BiomeMeta>) field.get(base);
  169.                     list.add(data);
  170.                     field.set(base, list);
  171.                 }
  172.             }
  173.             return true;
  174.         } catch (Exception e) {
  175.             e.printStackTrace();
  176.         }
  177.         return false;
  178.     }
  179.  
  180.     /**
  181.      * Adds a random spawn for the mob with the specified arguments.
  182.      * <p>
  183.      * If you're using a custom entity class, remember to <b>register</b> it before using this! Otherwise it'll not be
  184.      * rendered by the client.
  185.      * <p>
  186.      * If {@link #isAccessible()} returns false, the process will not be executed.
  187.      *
  188.      * @see #registerEntity(MobType, Class, boolean)
  189.      * @param type
  190.      *            - The mob type to spawn
  191.      * @param data
  192.      *            - The spawn data (chance, amount, spawn weight..)
  193.      * @param biomes
  194.      *            - The array of biomes to let the mobs spawn in, use {@link Biome#COLLECTION_ALL} for all of them.
  195.      * @see #addRandomSpawn(SpawnData, MobMeta, Biome...)
  196.      */
  197.     public static boolean addRandomSpawn(Type type, SpawnData data, Biome... biomes) {
  198.         if (type.isSpecial()) {
  199.             return false;
  200.         }
  201.         Field field;
  202.         if ((field = type.getMeta().getField()) == null) {
  203.             return false;
  204.         }
  205.         try {
  206.             field.setAccessible(true);
  207.             for (Biome biome : biomes) {
  208.                 BiomeBase[] array = biome.getNMSBiomeArray();
  209.                 for (BiomeBase base : array) {
  210.                     @SuppressWarnings("unchecked")
  211.                     List<BiomeMeta> list = (List<BiomeMeta>) field.get(base);
  212.                     list.add(data);
  213.                     field.set(base, list);
  214.                 }
  215.             }
  216.             return true;
  217.         } catch (Exception e) {
  218.             e.printStackTrace();
  219.         }
  220.         return false;
  221.     }
  222.  
  223.     /**
  224.      * Registers your entity without an internal id like most of the mobs have. Not sure where you'd need this but here
  225.      * you go.
  226.      * <p>
  227.      * Can still be spawned via /summon.
  228.      *
  229.      * <p>
  230.      * <b>Note: </b>Since no mob Type can be provided, overriding default mobs is not possible.
  231.      *
  232.      * @param name
  233.      *            - The 'savegame id' of your mob (ex. "custom_zombie")
  234.      * @param clazz
  235.      *            - The class of your custom entity
  236.      */
  237.     public static void registerWithoutID(String name, Class<? extends Entity> clazz) {
  238.         MinecraftKey key = new MinecraftKey(name);
  239.         EntityTypes.b.a(key, clazz);
  240.         if (!EntityTypes.d.contains(key)) {
  241.             EntityTypes.d.add(key);
  242.         }
  243.     }
  244.  
  245.     /**
  246.      * Registers the custom class to be available for use.
  247.      *
  248.      * @param type
  249.      *            - The type of your mob
  250.      * @param customClass
  251.      *            - Your custom class that'll be used
  252.      * @param override
  253.      *            - Should your mob be set as a default in each biome? Only one custom entity of this type entity can
  254.      *            have this set as 'true'.
  255.      */
  256.     public static void registerEntity(Type type, Class<? extends Entity> customClass, boolean override) {
  257.         NMSUtils.registerEntity(type.getName(), type, customClass, override);
  258.     }
  259.  
  260.     /**
  261.      * Registers the custom class to be available for use.
  262.      *
  263.      * @param id
  264.      *            - The mob id. BE CAREFUL with this. Your Minecraft client renders the entity based on this, and if
  265.      *            used improperly, will cause unexpected behavior!
  266.      * @param name
  267.      *            - The 'savegame id' of the mob.
  268.      * @param type
  269.      *            - The type of your mob
  270.      * @param customClass
  271.      *            - Your custom class that'll be used
  272.      * @param biomes
  273.      *            - The array of biomes to make the mob spawn in.
  274.      * @see #registerEntity(int, String, MobType, Class, Biome[])
  275.      * @see EntityType#getName() EntityType#getName() for the savegame id.
  276.      * @see EntityType#getId() EntityType#getId() for the correct mob id.
  277.      */
  278.     @SuppressWarnings("unchecked")
  279.     public static void registerEntity(String name, Type type, Class<? extends Entity> customClass, Biome... biomes) {
  280.         MinecraftKey key = new MinecraftKey(name);
  281.         EntityTypes.b.a(type.id, key, customClass);
  282.         if (!EntityTypes.d.contains(key)) {
  283.             EntityTypes.d.add(key);
  284.         }
  285.         if (biomes.length == 0 || type.isSpecial()) {
  286.             return;
  287.         }
  288.         Field field;
  289.         if ((field = type.getMeta().getField()) == null) {
  290.             return;
  291.         }
  292.         try {
  293.             field.setAccessible(true);
  294.             for (Biome biome : biomes) {
  295.                 BiomeBase[] array = biome.getNMSBiomeArray();
  296.                 for (BiomeBase base : array) {
  297.                     List<BiomeMeta> list = (List<BiomeMeta>) field.get(base);
  298.                     for (BiomeMeta meta : list) {
  299.                         if (meta.b == type.getNMSClass()) {
  300.                             meta.b = (Class<? extends EntityInsentient>) customClass;
  301.                             break;
  302.                         }
  303.                     }
  304.                 }
  305.             }
  306.         } catch (Exception e) {
  307.             e.printStackTrace();
  308.         }
  309.     }
  310.  
  311.     /**
  312.      * Registers the custom class to be available for use.
  313.      *
  314.      * @param name
  315.      *            - The 'savegame id' of the mob.
  316.      * @param type
  317.      *            - The type of your mob
  318.      * @param customClass
  319.      *            - Your custom class that'll be used
  320.      * @param override
  321.      *            - Should your mob be set as a default in each biome? Only one custom entity of this type entity can
  322.      *            have this set as 'true'.
  323.      * @see #registerEntity(int, String, MobType, Class, Biome[])
  324.      * @see EntityType#getName() EntityType#getName() for the savegame id.
  325.      */
  326.     @SuppressWarnings("unchecked")
  327.     public static void registerEntity(String name, Type type, Class<? extends Entity> customClass, boolean override) {
  328.         MinecraftKey key = new MinecraftKey(name);
  329.         EntityTypes.b.a(type.getId(), key, customClass);
  330.         if (!EntityTypes.d.contains(key)) {
  331.             EntityTypes.d.add(key);
  332.         }
  333.         if (!override || type.isSpecial()) {
  334.             return;
  335.         }
  336.         Field field;
  337.         if ((field = type.getMeta().getField()) == null) {
  338.             return;
  339.         }
  340.         try {
  341.             field.setAccessible(true);
  342.             for (BiomeBase base : NMSUtils.BIOMES) {
  343.                 List<BiomeMeta> list = (List<BiomeMeta>) field.get(base);
  344.                 for (BiomeMeta meta : list) {
  345.                     if (meta.b == type.getNMSClass()) {
  346.                         meta.b = (Class<? extends EntityInsentient>) customClass;
  347.                         break;
  348.                     }
  349.                 }
  350.             }
  351.         } catch (Exception e) {
  352.             e.printStackTrace();
  353.         }
  354.     }
  355.  
  356.     /**
  357.      * An enum containing all the biomes of Minecraft. The descriptions are taken from the
  358.      * <a href="http://minecraft.gamepedia.com/Biome">Minecraft Wiki Page</a>, which also has images for each biome.
  359.      *
  360.      */
  361.     public enum Biome {
  362.  
  363.         /**
  364.          * A large, open biome made entirely of water going up to y=63, with underwater relief on the sea floor, such as
  365.          * small mountains and plains, usually including gravel. Oceans typically extend under 3,000 blocks in any
  366.          * direction, around 60% of the Overworld's surface is covered in Ocean. Small islands with infrequent
  367.          * vegetation can be found in oceans. Passive mobs are unable to spawn on these islands, but hostiles can.
  368.          * Cavern entrances can be found infrequently at the bottom of the ocean. In the Console versions, they surround
  369.          * the edges of the map.
  370.          */
  371.         OCEAN(0),
  372.         /**
  373.          * A relatively flat and grassy biome with rolling hills and few trees. Gullies, water holes, and NPC villages
  374.          * are common. Cave openings and water or lava springs are easily identifiable due to the flat unobstructed
  375.          * terrain. Passive mobs spawn often in plains biomes; this biome and its variants are also one of the only
  376.          * biomes where horses spawn naturally.
  377.          */
  378.         PLAINS(1),
  379.         /**
  380.          * A barren and relatively inhospitable biome consisting mostly of sand dunes, dead bushes, and cacti. Sandstone
  381.          * is commonly found underneath the sand. The only passive mobs to spawn naturally in deserts are gold rabbits,
  382.          * their coloring well-camouflaged against the sand. Sugar cane can be found if the desert is next to an ocean
  383.          * or river biome. The lack of visual obstruction makes mobs highly visible at night. Desert villages, desert
  384.          * wells and desert temples are found exclusively in this biome. This biome sometimes appear as edge of mesa
  385.          * biome.
  386.          */
  387.         DESERT(2),
  388.         /**
  389.          * A highland biome (with some mountaintops reaching y=130 or even higher) with a few scattered oak and spruce
  390.          * trees. Cliffs, peaks, valleys, waterfalls, overhangs, floating islands, caverns, and many other structures
  391.          * exist, offering outstanding views. This is one of the few biomes where llamas spawn naturally. Snowfall also
  392.          * occurs above certain heights, thus creating "snow caps" on the top of the mountains. Falling is a significant
  393.          * risk, as there are many steep ledges large enough to cause severe fall damage or even death. Extreme hills
  394.          * are the only biomes where emerald ores and silverfish can be found naturally.
  395.          */
  396.         EXTREME_HILLS(3),
  397.         /**
  398.          * A biome with a lot of oak and birch trees, occasional hills, and a fair amount of tall grass. Mushrooms and
  399.          * flowers can occasionally be found here. This is one of the most preferred biomes to start out in, due to the
  400.          * abundance of wood. However, the frequency of trees also makes it dangerous to navigate at night, due to
  401.          * obscured vision. Forest biomes are also one of the smallest biomes.
  402.          */
  403.         FOREST(4),
  404.         /**
  405.          * A biome densely filled with spruce trees, ferns and large ferns. Wolves tend to spawn here fairly commonly.
  406.          */
  407.         TAIGA(5),
  408.         /**
  409.          * A biome characterized by a mix of flat, dry areas around sea level and shallow pools of brackish green water
  410.          * with floating lily pads. Clay, sand, and dirt are commonly found at the bottom of these pools. Trees are
  411.          * often covered with dark green vines, and can be found growing out from the water. Witch huts generate
  412.          * exclusively in swamps. Slimes will also spawn naturally at night, most commonly on full moons, making this an
  413.          * especially dangerous biome at night. Temperature varies randomly within the biome, not affected by altitude,
  414.          * causing foliage and grass colors to vary.
  415.          */
  416.         SWAMPLAND(6),
  417.         /**
  418.          * A biome that consists of water blocks that form an elongated, curving shape similar to a real river. Unlike
  419.          * real rivers, however, they have no current. Rivers cut through terrain or separate the main biomes. They
  420.          * attempt to join up with ocean on the other side, but will sometimes loop around to the same area of ocean.
  421.          * Rarely, they can have no connection to the ocean and form a circle. They have a dull green grass hue, much
  422.          * like the ocean, and trace amounts of oak trees tend to generate there as well. Rivers are also a reliable
  423.          * source of clay. These biomes are good for fishing.
  424.          */
  425.         RIVER(7),
  426.         /**
  427.          * This is the biome used to generate the Nether. In a Superflat world using this biome, the Overworld will
  428.          * contain only Nether mobs (ghasts, packs of zombie pigmen and occasional magma cubes) and won't receive rain,
  429.          * but it won't have Nether structures (such as Nether quartz or glowstone veins or Nether fortresses), and it
  430.          * can still have water lakes and mineshafts, beds will also explode in this biome, even when in the Overworld.
  431.          */
  432.         HELL(8),
  433.         /**
  434.          * This biome is used to generate the End. The ender dragon, and large amounts of endermen, spawn in this biome.
  435.          * Most of the End's structure is provided by the dimension itself rather than the biome. It does not rain or
  436.          * snow in this biome unlike the other low temperature biomes. The outer islands in the End can be accessed
  437.          * using the End gateway portal after the ender dragon has been defeated. These contain endermen, chorus plants
  438.          * and End cities. End cites are the only place where shulkers naturally spawn .If the biome is used for a
  439.          * superflat world, the sky will be dark gray and an ender dragon will spawn at 0,0 coordinates in the
  440.          * Overworld. Only endermen will spawn at night.
  441.          */
  442.         SKY(9),
  443.         /**
  444.          * A variant of the ocean biome that is completely frozen over. However, warmer rivers occasionally run through
  445.          * it. Doesn't generate in default worlds, but can be accessed using the Customized world type.
  446.          */
  447.         FROZEN_OCEAN(10),
  448.         /**
  449.          * This variant of river only generates in ice plains biomes. The surface layer of water is frozen.
  450.          */
  451.         FROZEN_RIVER(11),
  452.         /**
  453.          * A somewhat rare but expansive, flat biome with a huge amount of snow. All sources of water exposed to the sky
  454.          * are frozen over. Sugar cane will generate in this biome, but can become uprooted when chunks load as the
  455.          * water sources freeze to ice. There are very few natural oak and spruce trees in this biome. It has a lower
  456.          * chance of spawning passive mobs during world generation than other biomes (7% versus 10%), however it is one
  457.          * of the few biomes where Polar bears and Strays spawn. Due to the biome's size, snow and ice cover, and
  458.          * scarcity of wood and animals, initial survival becomes difficult in comparison to other biomes.
  459.          */
  460.         ICE_PLAINS(12),
  461.         /**
  462.          * Snowy hills that generate in the {@link #ICE_PLAINS}. Ice Mountains are usually taller, with height
  463.          * comparable to Extreme Hills biomes, and has a lower chance of spawning passive mobs during world generation
  464.          * than other biomes (7% versus 10%).
  465.          */
  466.         ICE_MOUNTAINS(13),
  467.         /**
  468.          * This rare biome consists of a mixture of flat landscape and steep hills and has mycelium instead of grass as
  469.          * its surface. However, if you do place down grass, it is a very bright green color, not unlike that of the
  470.          * jungle. Mushroom islands are most often adjacent to an ocean and are often found isolated from other biomes.
  471.          * It is one of the only biomes where huge mushrooms can generate naturally, and where mushrooms can grow in
  472.          * full sunlight.
  473.          *
  474.          * <p>
  475.          * Technically no mobs other than mooshrooms spawn naturally in this biome, including the usual night-time
  476.          * hostile mobs. This also applies to caves, abandoned mine shafts, and other dark structures, meaning exploring
  477.          * underground is supposedly safe. However, mob spawners will still spawn mobs, and the player will also still
  478.          * be able to breed animals and spawn mobs using eggs.
  479.          */
  480.         MUSHROOM_ISLAND(14),
  481.         /**
  482.          * Mushroom shores represent the flat shore area of the mushroom biome.
  483.          */
  484.         MUSHROOM_ISLAND_SHORE(15),
  485.         /**
  486.          * Generated on the shores of oceans, beaches are composed of sand. Beaches penetrate the landscape, removing
  487.          * the original blocks and placing in sand blocks. Some beaches generate with gravel instead of sand. These are
  488.          * also useful for fishing.
  489.          */
  490.         BEACHES(16),
  491.         /**
  492.          * Basically its respective base biome, {@link #DESERT}, but partially taller.
  493.          */
  494.         DESERT_HILLS(17),
  495.         /**
  496.          * Basically its respective base biome, {@link #FOREST}, but partially taller.
  497.          */
  498.         FOREST_HILLS(18),
  499.         /**
  500.          * Basically its respective base biome, {@link #TAIGA}, but partially taller.
  501.          */
  502.         TAIGA_HILLS(19),
  503.         /**
  504.          * Similar to the jungle edge sub-biome, this sub-biome generates exclusively at the edge of extreme hills
  505.          * biomes (or any variant). Doesn't generate in default worlds, but can be accessed using the Customized world
  506.          * type.
  507.          */
  508.         EXTREME_HILLS_EDGE(20),
  509.         /**
  510.          * A very dense, but rather uncommon tropical biome. It features large jungle trees that can reach up to 31
  511.          * blocks tall with 2×2 thick trunks. Oak trees are also common. The landscape is lush green and quite hilly,
  512.          * with many small lakes of water often nestled into deep valleys, sometimes above sea level. Leaves cover much
  513.          * of the forest floor—these "bush trees" have single-blocks of jungle wood for trunks, surrounded by oak
  514.          * leaves. When inside a jungle, the sky will become noticeably lighter. Vines are found alongside most blocks
  515.          * and may cover the surface of caves. Ocelots, jungle temples, melons, and cocoa plants can be found
  516.          * exclusively in this biome. Melons generate in small patches, similar to pumpkins.
  517.          */
  518.         JUNGLE(21),
  519.         /**
  520.          * Basically its respective base biome, {@link #JUNGLE}, but partially taller.
  521.          */
  522.         JUNGLE_HILLS(22),
  523.         /**
  524.          * A very rare biome that only generates at the border of a jungle biome and any other biome. Similar to a
  525.          * jungle but with much fewer and smaller trees, and relatively flat terrain.
  526.          */
  527.         JUNGLE_EDGE(23),
  528.         /**
  529.          * A variation of the Ocean biome. In deep ocean biomes, the ocean can exceed 30 blocks in depth, making it
  530.          * twice as deep as the normal ocean. In contrast to default oceans, the ground is mainly covered with gravel.
  531.          * Ocean monuments generate in deep oceans, which spawn guardians.
  532.          */
  533.         DEEP_OCEAN(24),
  534.         /**
  535.          * This stone-covered biome often appears adjacent to mountains and the ocean. Depending on the height of the
  536.          * nearby land, it can generate medium slopes or huge cliffs.
  537.          */
  538.         STONE_BEACH(25),
  539.         /**
  540.          * A beach with snowy weather conditions. Often found when the Ice Plain biome borders an ocean biome.
  541.          */
  542.         COLD_BEACH(26),
  543.         /**
  544.          * A forest made solely out of birch trees.
  545.          */
  546.         BIRCH_FOREST(27),
  547.         /**
  548.          * Basically its respective base biome, {@link #BIRCH_FOREST}, but partially taller.
  549.          */
  550.         BIRCH_FOREST_HILLS(28),
  551.         /**
  552.          * This biome is composed of dark oak trees, a mostly closed roof of leaves, and occasional large mushrooms.
  553.          * Trees in this forest are so plentiful and so close together, that at some spots it may become dark enough for
  554.          * hostile mobs to spawn, even during the day. Rarely, a woodland mansion may spawn
  555.          */
  556.         ROOFED_FOREST(29),
  557.         /**
  558.          * A snowy variation of the taiga biome, where ferns(and large ferns) and spruce trees grow. It is one of the
  559.          * few places where wolves will naturally spawn.
  560.          */
  561.         COLD_TAIGA(30),
  562.         /**
  563.          * Basically its respective base biome, {@link #COLD_TAIGA}, but partially taller.
  564.          */
  565.         COLD_TAIGA_HILLS(31),
  566.         /**
  567.          * Mega taiga is an uncommon biome composed of spruce trees, much like the standard taiga biome. However, some
  568.          * trees are 2×2 thick and very tall, not unlike large jungle trees. Moss stone boulders appear frequently,
  569.          * brown mushrooms are common and podzol can be found along the forest floor. There are also patches of coarse
  570.          * dirt, which will not grow grass. Wolves may also spawn here, as they do in normal taiga biomes.
  571.          */
  572.         MEGA_TAIGA(32),
  573.         /**
  574.          * Basically its respective base biome, {@link #MEGA_TAIGA}, but partially taller.
  575.          */
  576.         MEGA_TAIGA_HILLS(33),
  577.         /**
  578.          * A variant of the regular extreme hills biome, adding larger mountains, steeper cliffs, and a moderate amount
  579.          * of spruce trees and scattered oak trees.
  580.          */
  581.         EXTREME_HILLS_WITH_TREES(34),
  582.         /**
  583.          * A relatively flat and dry biome with a dry grass color and scattered acacia trees. Villages can generate in
  584.          * this biome, and it is the only biome where both horses and llamas spawn naturally.
  585.          */
  586.         SAVANNA(35),
  587.         /**
  588.          * Variation of the {@link #SAVANNA} biome. Like the hills biomes, but flattened at the top, coming to rest at
  589.          * about 20 to 30 blocks above sea level.
  590.          */
  591.         SAVANNA_PLATEAU(36),
  592.         /**
  593.          * A rare biome consisting of hardened clay, stained clay, and dead bushes – similar to a desert. Red sand
  594.          * will also generate here instead of regular sand, with occasional cacti. Its composition is useful when other
  595.          * sources of clay are scarce. However, finding mesa biomes can be difficult due to their rarity. On the other
  596.          * hand, it offers great variety - there are a total of 6 variations of this biome to explore.
  597.          *
  598.          * <p>
  599.          * Mesas can contain above ground abandoned mineshafts. They also allow gold ore to generate near surface
  600.          * levels, rather than just at layer 32 and below.
  601.          */
  602.         MESA(37),
  603.         /**
  604.          * A rare variation of the mesa plateau, where small forests of dry oak trees and grass generate at the top of
  605.          * the plateaus.
  606.          */
  607.         MESA_PLATEAU_F(38),
  608.         /**
  609.          * Variation of the {@link #MESA} bioime. Like the hills biomes, but flattened at the top, coming to rest at
  610.          * about 20 to 30 blocks above sea level. Only generates in savanna and mesa biomes.
  611.          */
  612.         MESA_PLATEAU(39),
  613.         /**
  614.          * A completely empty biome that generates only a single structure: a 33×33 stone platform with a single block
  615.          * of cobblestone in the center. No mobs (passive or hostile) can spawn without spawn eggs, monster spawners or
  616.          * commands. Can only be accessed through The Void superflat preset.
  617.          */
  618.         VOID(127),
  619.         /**
  620.          * A rare variation of the plains biome, where sunflowers naturally spawn in abundance.
  621.          */
  622.         SUNFLOWER_PLAINS(129),
  623.         /**
  624.          * Unlike in normal deserts, patches of water can be found in this biome.
  625.          */
  626.         DESERT_M(130),
  627.         /**
  628.          * Variant of the regular extreme hills biome that features higher mountain peaks, most of which reach into the
  629.          * clouds. Mountains here are composed mainly of gravel and a little bit of dirt and grass, with a sparse
  630.          * population of spruce and oak trees.
  631.          */
  632.         EXTREME_HILLS_M(131),
  633.         /**
  634.          * A variant of the forest biome that has fewer trees but has a huge amount of various flowers. There are
  635.          * certain flowers that are exclusive to the flower forest.
  636.          */
  637.         FLOWER_FOREST(132),
  638.         /**
  639.          * Mountainous version of the regular taiga biome.
  640.          */
  641.         TAIGA_M(133),
  642.         /**
  643.          * A slightly hillier swampland with greener grass. Witch huts do not generate in this biome, unlike the normal
  644.          * swampland biome.
  645.          */
  646.         SWAMPLAND_M(134),
  647.         /**
  648.          * A rare variation of the Ice Plains biome that features large spikes of packed ice, as well as packed ice
  649.          * 'lakes'. Usually the spikes are 10 to 20 blocks tall, but some long, thin spikes can reach over 50 blocks in
  650.          * height. All grass blocks in this biome are replaced with blocks of snow. It has a lower chance of spawning
  651.          * passive mobs during world generation than other biomes (7% versus 10%).
  652.          */
  653.         ICE_SPIKES(140),
  654.         /**
  655.          * Much more mountainous version of the normal jungle, with foliage so thick that the ground is barely visible.
  656.          * A very resource-demanding biome. Due to the hilly nature of the terrain in this biome, and the height of the
  657.          * tall jungle trees, trees frequently reach into and go above the clouds. Extremely dense foliage and
  658.          * treacherous hilly terrain make this a very difficult biome to navigate, especially at night.
  659.          */
  660.         JUNGLE_M(149),
  661.         /**
  662.          * The rarest biome in Minecraft. A slightly more mountainous variation of the jungle edge biome, which only
  663.          * generates on the border of a jungle M and another biome. There are very few to no tall trees in this
  664.          * relatively tiny biome.
  665.          */
  666.         JUNGLE_EDGE_M(151),
  667.         /**
  668.          * A variation of the birch forest biome which features taller birch trees than usual.
  669.          */
  670.         BIRCH_FOREST_M(155),
  671.         /**
  672.          * Basically its respective base biome, {@link #BIRCH_FOREST_M}, but partially taller.
  673.          */
  674.         BIRCH_FOREST_HILLS_M(156),
  675.         /**
  676.          * A mountainous version of the roofed forest biome, with steep cliffs lining the edge.
  677.          */
  678.         ROOFED_FOREST_M(157),
  679.         /**
  680.          * Large, mountainous version of the snowy {@link #COLD_TAIGA}.
  681.          */
  682.         COLD_TAIGA_M(158),
  683.         /**
  684.          * A variation of the mega taiga. In this biome there is a much higher density of smaller spruce trees. Also,
  685.          * the tall trees look very similar to regular spruce trees, as opposed to the short-topped trees in the normal
  686.          * mega taiga biome.
  687.          */
  688.         MEGA_SPRUCE_TAIGA(160),
  689.         /**
  690.          * Basically its respective base biome, {@link #MEGA_SPRUCE_TAIGA}, but partially taller.
  691.          */
  692.         REDWOOD_TAIGA_HILLS_M(161),
  693.         /**
  694.          * A rare variant of the extreme hills+ biome where huge gravel mountains appear, with sparse oak and spruce
  695.          * trees and small patches of grass.
  696.          */
  697.         EXTREME_HILLS_PLUS_M(162),
  698.         /**
  699.          * Variant of the savanna biome. Dirt paths and giant mountains are prevalent in this biome. However, this biome
  700.          * is unique in that its mountains can generate past the clouds, and even to the world height limit, without
  701.          * using the AMPLIFIED world type.
  702.          */
  703.         SAVANNA_M(163),
  704.         /**
  705.          * The savanna plateau M biome features incredibly large and steep cliffs that jut violently out of the terrain,
  706.          * compared to the regular savanna plateau; these cliffs generally exceed cloud height, sometimes above y=200,
  707.          * and sometimes even border the world height limit.
  708.          */
  709.         SAVANNA_PLATEAU_M(164),
  710.         /**
  711.          * Mesa (Bryce) is a variant of the mesa biome, featuring a low desert-like ground area with tall, thin,
  712.          * spire-shaped columns of hardened clay, similar to the structures in the real Bryce Canyon.
  713.          */
  714.         MESA_BRYCE(165),
  715.         /**
  716.          * Very rare variant of the Mesa Plateau F biome. Features steeper cliffs than the normal Mesa Plateau F biome,
  717.          * with a reduced occurrence of trees and smaller, more erratic hills.
  718.          */
  719.         MESA_PLATEAU_F_M(166),
  720.         /**
  721.          * The mesa plateau M biome features slightly flatter terrain and smaller plateaus in general, compared to the
  722.          * average mesa plateau biome.
  723.          */
  724.         MESA_PLATEAU_M(167),
  725.         /**
  726.          * A Collection of all mesa biomes.
  727.          */
  728.         COLLECTION_MESA(37, 38, 39, 165, 166, 167),
  729.         /**
  730.          * A Collection of all forest biomes - excluding swamplands, jungles and extreme hills with trees. 16 biomes in
  731.          * total.
  732.          */
  733.         COLLECTION_FORESTS_ALL(4, 18, 27, 28, 29, 30, 31, 32, 33, 132, 133, 155, 156, 157, 158, 160),
  734.         /**
  735.          * A Collection consisting of all 3 desert biomes; {@link #DESERT}, {@link #DESERT_HILLS} and {@link #DESERT_M}.
  736.          */
  737.         COLLECTION_DESERTS(2, 17, 130),
  738.         /**
  739.          * A Collection of all 3 plains; consisting of {@link #PLAINS}, {@link #SUNFLOWER_PLAINS} and
  740.          * {@link #ICE_PLAINS}.
  741.          */
  742.         COLLECTION_PLAINS(1, 12, 129),
  743.         /**
  744.          * A Collection consisting of all 5 icy biomes; {@link #ICE_MOUNTAINS}, {@link #ICE_PLAINS}, {@link #ICE_SPIKES}
  745.          * , {@link #FROZEN_OCEAN} and {@link #FROZEN_RIVER}.
  746.          */
  747.         COLLECTION_ICY_BIOMES(12, 13, 10, 11, 140),
  748.         /**
  749.          * A Collection consisting of all taiga biomes - including mega- and cold taigas. 8 biomes in total.
  750.          */
  751.         COLLECTION_TAIGA(30, 31, 32, 33, 133, 158, 161, 5),
  752.         /**
  753.          * A Collection consisting of all 5 water-y biomes, oceans and rivers.
  754.          */
  755.         COLLECTION_WATER(0, 7, 10, 11, 24),
  756.         /**
  757.          * A Collection consisting of all 3 beaches; {@link #BEACHES}, {@link #STONE_BEACH} and {@link #COLD_BEACH}.
  758.          */
  759.         COLLECTION_BEACHES(16, 25, 26),
  760.         /**
  761.          * A Collection consisting of all 5 jungle biomes; {@link #JUNGLE}, {@link #JUNGLE_M}, {@link #JUNGLE_HILLS},
  762.          * {@link #JUNGLE_EDGE} and {@link #JUNGLE_EDGE_M}.
  763.          */
  764.         COLLECTION_JUNGLE(21, 22, 23, 149, 151),
  765.         /**
  766.          * A Collection consisting of all 4 extreme hills biomes; {@link #EXTREME_HILLS_EDGE}, {@link #EXTREME_HILLS_M},
  767.          * {@link #EXTREME_HILLS_PLUS_M} , {@link #EXTREME_HILLS_WITH_TREES} and {@link #EXTREME_HILLS}.
  768.          */
  769.         COLLECTION_EXTREME_HILLS(3, 20, 34, 131, 162),
  770.         /**
  771.          * A Collection consisting of the two swampland biomes; {@link #SWAMPLAND} and {@link #SWAMPLAND_M}.
  772.          */
  773.         COLLECTION_SWAMPLAND(6, 134),
  774.         /**
  775.          * A Collection consisting of all x savanna variants; {@link #SAVANNA_M}, {@link #SAVANNA_PLATEAU_M},
  776.          * {@link #SAVANNA_PLATEAU} and {@link #SAVANNA}.
  777.          */
  778.         COLLECTION_SAVANNA(35, 36, 163, 164),
  779.         /**
  780.          * ~lé sigh~ A Collection consisting of every single biome type in the game.
  781.          */
  782.         COLLECTION_ALL(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 127, 129, 130, 131, 132, 133, 134, 140, 149, 151, 155, 156, 157, 158, 160, 161, 162, 163, 164, 165, 166, 167);
  783.         private static Biome[] ID_LOOKUP_TABLE = new Biome[168];
  784.  
  785.         private BiomeBase[] biomes;
  786.         private BiomeBase biome;
  787.  
  788.         private Biome(int... ids) {
  789.             assert ids.length > 0;
  790.             this.biomes = new BiomeBase[ids.length];
  791.             for (int i = 0; i < this.biomes.length; ++i) {
  792.                 this.biomes[i] = BiomeBase.REGISTRY_ID.getId(ids[i]);
  793.             }
  794.             this.biome = this.biomes[0];
  795.         }
  796.  
  797.         public BiomeBase asNMSBiome() {
  798.             return this.biome;
  799.         }
  800.  
  801.         public BiomeBase[] getNMSBiomeArray() {
  802.             return this.biomes;
  803.         }
  804.  
  805.         public static Biome fromId(int id) {
  806.             return Biome.ID_LOOKUP_TABLE[id];
  807.         }
  808.  
  809.         static {
  810.             Biome[] values = Biome.values();
  811.             for (Biome biome : values) {
  812.                 Biome.ID_LOOKUP_TABLE[BiomeBase.REGISTRY_ID.a(biome.biome)] = biome;
  813.             }
  814.         }
  815.     }
  816.  
  817.     public enum Type {
  818.         DROPPED_ITEM(1, "item", EntityItem.class, MobMeta.UNDEFINED, true),
  819.         EXPERIENCE_ORB(2, "xp_orb", EntityExperienceOrb.class, MobMeta.UNDEFINED, true),
  820.         AREA_EFFECT_CLOUD(3, "area_effect_cloud", EntityAreaEffectCloud.class, MobMeta.UNDEFINED, true),
  821.         ELDER_GUARDIAN(4, "elder_guardian", EntityGuardianElder.class, MobMeta.MONSTER, false),
  822.         WITHER_SKELETON(5, "wither_skeleton", EntitySkeletonWither.class, MobMeta.MONSTER, false),
  823.         STRAY(6, "stray", EntitySkeletonStray.class, MobMeta.MONSTER, false),
  824.         THROWN_EGG(7, "egg", EntityEgg.class, MobMeta.UNDEFINED, true),
  825.         LEAD_KNOT(8, "leash_knot", EntityLeash.class, MobMeta.UNDEFINED, true),
  826.         PAINTING(9, "painting", EntityPainting.class, MobMeta.UNDEFINED, true),
  827.         ARROW(10, "arrow", EntityArrow.class, MobMeta.UNDEFINED, true),
  828.         SNOWBALL(11, "snowball", EntitySnowball.class, MobMeta.UNDEFINED, true),
  829.         FIREBALL(12, "fireball", EntityFireball.class, MobMeta.UNDEFINED, true),
  830.         SMALL_FIREBALL(13, "fireball", EntitySmallFireball.class, MobMeta.UNDEFINED, true),
  831.         ENDER_PEARL(14, "ender_pearl", EntityEnderPearl.class, MobMeta.UNDEFINED, true),
  832.         EYE_OF_ENDER(15, "eye_of_ender_signal", EntityEnderSignal.class, MobMeta.UNDEFINED, true),
  833.         POTION(16, "potion", EntityPotion.class, MobMeta.UNDEFINED, true),
  834.         EXP_BOTTLE(17, "xp_bottle", EntityThrownExpBottle.class, MobMeta.UNDEFINED, true),
  835.         ITEM_FRAME(18, "item_frame", EntityItemFrame.class, MobMeta.UNDEFINED, true),
  836.         WITHER_SKULL(19, "wither_skull", EntityWitherSkull.class, MobMeta.UNDEFINED, true),
  837.         PRIMED_TNT(20, "tnt", EntityTNTPrimed.class, MobMeta.UNDEFINED, true),
  838.         FALLING_BLOCK(21, "falling_block", EntityFallingBlock.class, MobMeta.UNDEFINED, true),
  839.         FIREWORK_ROCKET(22, "fireworks_rocket", EntityFireworks.class, MobMeta.UNDEFINED, true),
  840.         HUSK(23, "husk", EntityZombieHusk.class, MobMeta.MONSTER, false),
  841.         SPECTRAL_ARROW(24, "spectral_arrow", EntitySpectralArrow.class, MobMeta.UNDEFINED, true),
  842.         SHULKER_BULLET(25, "shulker_bullet", EntityShulkerBullet.class, MobMeta.UNDEFINED, true),
  843.         DRAGON_FIREBALL(26, "dragon_fireball", EntityDragonFireball.class, MobMeta.UNDEFINED, true),
  844.         ZOMBIE_VILLAGER(27, "zombie_villager", EntityZombieVillager.class, MobMeta.MONSTER, false),
  845.         SKELETON_HORSE(28, "skeleton_horse", EntityHorseSkeleton.class, MobMeta.CREATURE, false),
  846.         ZOMBIE_HORSE(29, "zombie_horse", EntityHorseZombie.class, MobMeta.CREATURE, false),
  847.         ARMOR_STAND(30, "armor_stand", EntityArmorStand.class, MobMeta.UNDEFINED, true),
  848.         DONKEY(31, "donkey", EntityHorseDonkey.class, MobMeta.CREATURE, false),
  849.         MULE(32, "mule", EntityHorseMule.class, MobMeta.CREATURE, false),
  850.         EVOCATION_FANGS(33, "evocation_fangs", EntityEvokerFangs.class, MobMeta.UNDEFINED, true),
  851.         EVOKER(34, "evocation_illager", EntityEvoker.class, MobMeta.MONSTER, false),
  852.         VEX(35, "vex", EntityVex.class, MobMeta.MONSTER, false),
  853.         VINDICATOR(36, "vindication_illager", EntityVindicator.class, MobMeta.MONSTER, false),
  854.         ILLUSIONER(37, "illusion_illager", EntityIllagerIllusioner.class, MobMeta.MONSTER, false),
  855.         COMMAND_BLOCK_MINECART(40, "commandblock_minecart", EntityMinecartCommandBlock.class, MobMeta.UNDEFINED, true),
  856.         BOAT(41, "boat", EntityBoat.class, MobMeta.UNDEFINED, true),
  857.         MINECART(42, "minecart", EntityMinecartRideable.class, MobMeta.UNDEFINED, true),
  858.         CHEST_MINECART(43, "chest_minecart", EntityMinecartChest.class, MobMeta.UNDEFINED, true),
  859.         FURNACE_MINECART(44, "furnace_minecart", EntityMinecartFurnace.class, MobMeta.UNDEFINED, true),
  860.         TNT_MINECART(45, "tnt_minecart", EntityMinecartTNT.class, MobMeta.UNDEFINED, true),
  861.         HOPPER_MINECART(46, "hopper_minecart", EntityMinecartHopper.class, MobMeta.UNDEFINED, true),
  862.         SPAWNER_MINECART(47, "spawner_minecart", EntityMinecartMobSpawner.class, MobMeta.UNDEFINED, true),
  863.         CREEPER(50, "creeper", EntityCreeper.class, MobMeta.MONSTER, false),
  864.         SKELETON(51, "skeleton", EntitySkeleton.class, MobMeta.MONSTER, false),
  865.         SPIDER(52, "spider", EntitySpider.class, MobMeta.MONSTER, false),
  866.         GIANT(53, "giant", EntityGiantZombie.class, MobMeta.MONSTER, false),
  867.         ZOMBIE(54, "zombie", EntityZombie.class, MobMeta.MONSTER, false),
  868.         SLIME(55, "slime", EntitySlime.class, MobMeta.MONSTER, false),
  869.         GHAST(56, "ghast", EntityGhast.class, MobMeta.MONSTER, false),
  870.         PIG_ZOMBIE(57, "zombie_pigman", EntityPigZombie.class, MobMeta.MONSTER, false),
  871.         ENDERMAN(58, "enderman", EntityEnderman.class, MobMeta.MONSTER, false),
  872.         CAVE_SPIDER(59, "cave_spider", EntityCaveSpider.class, MobMeta.MONSTER, false),
  873.         SILVERFISH(60, "silverfish", EntitySilverfish.class, MobMeta.MONSTER, false),
  874.         BLAZE(61, "blaze", EntityBlaze.class, MobMeta.MONSTER, false),
  875.         MAGMACUBE(62, "magma_cube", EntityMagmaCube.class, MobMeta.MONSTER, false),
  876.         ENDER_DRAGON(63, "ender_dragon", EntityEnderDragon.class, MobMeta.MONSTER, false),
  877.         WITHER(64, "wither", EntityWither.class, MobMeta.MONSTER, false),
  878.         BAT(65, "bat", EntityBat.class, MobMeta.AMBIENT, false),
  879.         WITCH(66, "witch", EntityWitch.class, MobMeta.MONSTER, false),
  880.         ENDERMITE(67, "endermite", EntityEndermite.class, MobMeta.MONSTER, false),
  881.         GUARDIAN(68, "guardian", EntityGuardian.class, MobMeta.MONSTER, false),
  882.         SHULKER(69, "shulker", EntityShulker.class, MobMeta.MONSTER, false),
  883.         PIG(90, "pig", EntityPig.class, MobMeta.CREATURE, false),
  884.         SHEEP(91, "sheep", EntitySheep.class, MobMeta.CREATURE, false),
  885.         COW(92, "cow", EntityCow.class, MobMeta.CREATURE, false),
  886.         CHICKEN(93, "chicken", EntityChicken.class, MobMeta.CREATURE, false),
  887.         SQUID(94, "squid", EntitySquid.class, MobMeta.WATER_CREATURE, false),
  888.         WOLF(95, "wolf", EntityWolf.class, MobMeta.CREATURE, false),
  889.         MOOSHROOM(96, "mooshroom", EntityMushroomCow.class, MobMeta.CREATURE, false),
  890.         SNOWMAN(97, "snowman", EntitySnowman.class, MobMeta.CREATURE, false),
  891.         OCELOT(98, "ocelot", EntityOcelot.class, MobMeta.CREATURE, false),
  892.         IRON_GOLEM(99, "villager_golem", EntityIronGolem.class, MobMeta.CREATURE, false),
  893.         HORSE(100, "horse", EntityHorse.class, MobMeta.CREATURE, false),
  894.         RABBIT(101, "rabbit", EntityRabbit.class, MobMeta.CREATURE, false),
  895.         POLARBEAR(102, "polar_bear", EntityPolarBear.class, MobMeta.CREATURE, false),
  896.         LLAMA(103, "llama", EntityLlama.class, MobMeta.CREATURE, false),
  897.         LLAMA_SPIT(104, "llama_spit", EntityLlamaSpit.class, MobMeta.UNDEFINED, true),
  898.         PARROT(105, "parrot", EntityParrot.class, MobMeta.CREATURE, false),
  899.         VILLAGER(120, "villager", EntityVillager.class, MobMeta.CREATURE, false),
  900.         ENDER_CRYSTAL(200, "ender_crystal", EntityEnderCrystal.class, MobMeta.UNDEFINED, true);
  901.  
  902.         private int id;
  903.         private String name;
  904.         private Class<? extends Entity> clazz;
  905.         private MobMeta meta;
  906.         private boolean special;
  907.  
  908.         private Type(int id, String name, Class<? extends Entity> nmsClazz, MobMeta meta, boolean special) {
  909.             this.id = id;
  910.             this.name = name;
  911.             this.clazz = nmsClazz;
  912.             this.meta = meta;
  913.             this.special = special;
  914.         }
  915.  
  916.         public MobMeta getMeta() {
  917.             return this.meta;
  918.         }
  919.  
  920.         public int getId() {
  921.             return this.id;
  922.         }
  923.  
  924.         public String getName() {
  925.             return this.name;
  926.         }
  927.  
  928.         public Class<? extends Entity> getNMSClass() {
  929.             return this.clazz;
  930.         }
  931.  
  932.         public boolean isSpecial() {
  933.             return this.special;
  934.         }
  935.     }
  936.  
  937.     public enum MobMeta {
  938.         MONSTER(NMSUtils.META_LIST_MONSTER),
  939.         CREATURE(NMSUtils.META_LIST_CREATURE),
  940.         WATER_CREATURE(NMSUtils.META_LIST_WATER_CREATURE),
  941.         AMBIENT(NMSUtils.META_LIST_AMBIENT),
  942.         UNDEFINED(null);
  943.  
  944.         private Field field;
  945.  
  946.         private MobMeta(Field field) {
  947.             this.field = field;
  948.         }
  949.  
  950.         /**
  951.          * @return the BiomeMeta list field of this entity.
  952.          *         <p>
  953.          *         <b>Undefined will not be accepted and returns null.</b>
  954.          *         </p>
  955.          */
  956.         public Field getField() {
  957.             return this.field;
  958.         }
  959.     }
  960.  
  961.     public class NBTTagType {
  962.         public static final int COMPOUND = 10;
  963.         public static final int LIST = 9;
  964.         public static final int STRING = 8;
  965.         public static final int LONG_ARRAY = 12;
  966.         public static final int INT_ARRAY = 11;
  967.         public static final int BYTE_ARRAY = 7;
  968.         public static final int DOUBLE = 6;
  969.         public static final int FLOAT = 5;
  970.         public static final int LONG = 4;
  971.         public static final int INT = 3;
  972.         public static final int SHORT = 2;
  973.         public static final int BYTE = 1;
  974.         public static final int BOOLEAN = 1;
  975.         public static final int END = 0;
  976.     }
  977.  
  978.     public static enum Attributes {
  979.         MAX_HEALTH("generic.maxHealth", GenericAttributes.maxHealth),
  980.         MOVEMENT_SPEED("generic.movementSpeed", GenericAttributes.MOVEMENT_SPEED),
  981.         ATTACK_DAMAGE("generic.attackDamage", GenericAttributes.ATTACK_DAMAGE),
  982.         FOLLOW_RANGE("generic.followRange", GenericAttributes.FOLLOW_RANGE),
  983.         LUCK("generic.luck", GenericAttributes.j),
  984.         ARMOR("generic.armor", GenericAttributes.h),
  985.         ARMOR_TOUGHNESS("generic.armorToughness", GenericAttributes.i),
  986.         ATTACK_SPEED("generic.attackSpeed", GenericAttributes.g),
  987.         KNOCKBACK_RESISTANCE("generic.knockbackResistance", GenericAttributes.c);
  988.  
  989.         private String name;
  990.         private IAttribute attribute;
  991.  
  992.         private Attributes(String nmsName, IAttribute nmsAttribute) {
  993.             this.name = nmsName;
  994.             this.attribute = nmsAttribute;
  995.         }
  996.  
  997.         /**
  998.          * Returns the NMS name of the attribute. For example, <code>MAX_HEALTH</code> returns
  999.          * <code>"generic.maxHealth"</code>, and so on and so forth.
  1000.          *
  1001.          * @return The name as a String.
  1002.          */
  1003.         public String getName() {
  1004.             return this.name;
  1005.         }
  1006.  
  1007.         /**
  1008.          * @return the IAttribute value of this type, used in place of <code>GenericAttributes.h</code> (for
  1009.          *         Attributes.ARMOR as an example).
  1010.          */
  1011.         public IAttribute asIAttribute() {
  1012.             return this.attribute;
  1013.         }
  1014.     }
  1015.  
  1016.     public static class SpawnData extends BiomeMeta {
  1017.  
  1018.         /**
  1019.          * Creates a new instance of SpawnData, and at the same time, a new instanceof BiomeMeta, used to add random
  1020.          * spawns and such.
  1021.          *
  1022.          * @param customClass
  1023.          *            - Your class to spawn
  1024.          * @param spawnWeight
  1025.          *            - The chance for the mob(s) to spawn.
  1026.          * @param minSpawns
  1027.          *            - The minimum amount of entities spawned at once.
  1028.          * @param maxSpawns
  1029.          *            - The maximum amount of entities spawned at once.
  1030.          */
  1031.         public SpawnData(Class<? extends EntityInsentient> customClass, int spawnWeight, int minSpawns, int maxSpawns) {
  1032.             super(customClass, spawnWeight, minSpawns, maxSpawns);
  1033.         }
  1034.  
  1035.         public Class<? extends EntityInsentient> getCustomClass() {
  1036.             return this.b;
  1037.         }
  1038.  
  1039.         public int getSpawnWeight() {
  1040.             return this.a;
  1041.         }
  1042.  
  1043.         public int getMinSpawns() {
  1044.             return this.c;
  1045.         }
  1046.  
  1047.         public int getMaxSpawns() {
  1048.             return this.d;
  1049.         }
  1050.     }
  1051.  
  1052.     static {
  1053.         Class<BiomeBase> clazz = BiomeBase.class;
  1054.         Field monster = null;
  1055.         Field creature = null;
  1056.         Field water = null;
  1057.         Field ambient = null;
  1058.         try {
  1059.             // These fields may vary depending on your version.
  1060.             // The new names can be found under
  1061.             // net.minecraft.server.<version>.BiomeBase.class
  1062.             monster = clazz.getDeclaredField("t");
  1063.             creature = clazz.getDeclaredField("u");
  1064.             water = clazz.getDeclaredField("v");
  1065.             ambient = clazz.getDeclaredField("w");
  1066.         } catch (Exception e) {
  1067.             Bukkit.getLogger().warning("Wrong server version / software; BiomeMeta fields not found, aborting.");
  1068.         }
  1069.         META_LIST_MONSTER = monster;
  1070.         META_LIST_CREATURE = creature;
  1071.         META_LIST_WATER_CREATURE = water;
  1072.         META_LIST_AMBIENT = ambient;
  1073.         CRAFTBUKKIT_SERVER = (CraftServer) Bukkit.getServer();
  1074.         MINECRAFT_SERVER = NMSUtils.CRAFTBUKKIT_SERVER.getServer();
  1075.         BIOMES = new BiomeBase[BiomeBase.i.a()];
  1076.         Iterator<BiomeBase> iterator = BiomeBase.i.iterator();
  1077.         int index = 0;
  1078.         while (iterator.hasNext()) {
  1079.             NMSUtils.BIOMES[index++] = iterator.next();
  1080.         }
  1081.     }
  1082. }
Advertisement
RAW Paste Data Copied
Advertisement