Advertisement
HalestormXV

Untitled

Oct 26th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.06 KB | None | 0 0
  1. package com.halestormxv.Main.handler;
  2.  
  3. import java.util.Random;
  4.  
  5. import org.apache.commons.lang3.ArrayUtils;
  6.  
  7. import com.halestormxv.Main.MainRegistry;
  8. import com.halestormxv.Main.handler.network.PacketDispatcher;
  9. import com.halestormxv.Main.handler.network.packets.SyncPlayerPropsMessage;
  10. import com.halestormxv.entity.EntityCyclops;
  11. import com.halestormxv.entity.EntityLunarSpirit;
  12. import com.halestormxv.item.CelestialCraft_items;
  13.  
  14. import cpw.mods.fml.common.eventhandler.SubscribeEvent;
  15. import cpw.mods.fml.common.registry.EntityRegistry;
  16. import net.minecraft.entity.EntityList;
  17. import net.minecraft.entity.EntityLiving;
  18. import net.minecraft.entity.EnumCreatureType;
  19. import net.minecraft.entity.item.EntityItem;
  20. import net.minecraft.entity.monster.EntityMob;
  21. import net.minecraft.entity.player.EntityPlayer;
  22. import net.minecraft.entity.player.EntityPlayerMP;
  23. import net.minecraft.item.ItemStack;
  24. import net.minecraft.world.biome.BiomeGenBase;
  25. import net.minecraftforge.common.BiomeDictionary;
  26. import net.minecraftforge.common.BiomeDictionary.Type;
  27. import net.minecraftforge.event.entity.EntityJoinWorldEvent;
  28. import net.minecraftforge.event.entity.living.LivingDeathEvent;
  29. import net.minecraftforge.event.entity.living.LivingDropsEvent;
  30. import net.minecraftforge.event.entity.player.PlayerEvent;
  31.  
  32. public class EntityHandler {
  33.  
  34.     public static void registerMonster(Class entityClass, String name){
  35.         BiomeGenBase[] biomes = new BiomeGenBase[0];
  36.         biomes = ArrayUtils.addAll(biomes, BiomeDictionary.getBiomesForType(Type.DENSE));
  37.         biomes = ArrayUtils.addAll(biomes, BiomeDictionary.getBiomesForType(Type.FOREST));
  38.         biomes = ArrayUtils.addAll(biomes, BiomeDictionary.getBiomesForType(Type.RIVER));
  39.        
  40.         int entityId = EntityRegistry.findGlobalUniqueEntityId();
  41.         long x = name.hashCode();
  42.         Random random = new Random(x);
  43.         int mainColor = random.nextInt() * 16777215;
  44.         int subColor = random.nextInt() * 16777215;
  45.         EntityRegistry.registerGlobalEntityID(entityClass, name, entityId);
  46.         //EntityRegistry.addSpawn(entityClass, 64, 4, 6, EnumCreatureType.monster,  biomes);
  47.         addSpawnToBiomes();
  48.         EntityRegistry.registerModEntity(entityClass, name, entityId, MainRegistry.modInstance, 64, 1, true);
  49.         EntityList.entityEggs.put(Integer.valueOf(entityId), new EntityList.EntityEggInfo(entityId, mainColor, subColor));
  50.     }
  51.    
  52.     public static void addSpawnToBiomes()
  53.     {
  54.     EntityRegistry.addSpawn(EntityCyclops.class, 11, 4, 6, EnumCreatureType.monster, BiomeGenBase.mushroomIsland, BiomeGenBase.beach, BiomeGenBase.desert, BiomeGenBase.forest, BiomeGenBase.roofedForest, BiomeGenBase.plains, BiomeGenBase.river, BiomeGenBase.jungleHills, BiomeGenBase.jungle, BiomeGenBase.birchForest);
  55.     EntityRegistry.addSpawn(EntityLunarSpirit.class, 8, 1, 2, EnumCreatureType.monster, BiomeGenBase.forest, BiomeGenBase.roofedForest, BiomeGenBase.river, BiomeGenBase.jungleHills, BiomeGenBase.jungle, BiomeGenBase.birchForest);
  56.     }
  57.    
  58.     public static void registerItemEntity(Class entityClass, String name){
  59.         int entityId = EntityRegistry.findGlobalUniqueEntityId();
  60.         long x = name.hashCode();
  61.         Random random = new Random(x);
  62.         int mainColor = random.nextInt() * 16777215;
  63.         int subColor = random.nextInt() * 16777215;
  64.        
  65.         EntityRegistry.registerGlobalEntityID(entityClass, name, entityId);
  66.         EntityRegistry.registerModEntity(entityClass, name, entityId, MainRegistry.modInstance, 64, 1, true);
  67.         EntityList.entityEggs.put(Integer.valueOf(entityId), new EntityList.EntityEggInfo(entityId, mainColor, subColor));
  68.     }
  69.    
  70.     public static void registerSummon(Class entityClass, String name){
  71.         int entityId = EntityRegistry.findGlobalUniqueEntityId();
  72.         long x = name.hashCode();
  73.         Random random = new Random(x);
  74.         int mainColor = random.nextInt() * 16777215;
  75.         int subColor = random.nextInt() * 16777215;    
  76.         EntityRegistry.registerGlobalEntityID(entityClass, name, entityId);
  77.         EntityRegistry.registerModEntity(entityClass, name, entityId, MainRegistry.modInstance, 64, 1, true);
  78.         EntityList.entityEggs.put(Integer.valueOf(entityId), new EntityList.EntityEggInfo(entityId, mainColor, subColor));
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement