jabelar Posted April 13, 2014 Posted April 13, 2014 Okay, I'm getting confused between the use of the EntityRegistry.registerGlobalEntityID() and the EntityRegistry.registerModEntity() methods for entity registration because I looked at four tutorials that give conflicting advice... A tutorial here (http://www.minecraftforge.net/wiki/How_to_register_a_mob_entity#Registering_an_Entity) indicates to only use the registerGlobalEntityID(). It says: Put the following in your mod file's load() method: EntityRegistry.registerGlobalEntityID(MyEntity.class, "MyEntityName", myentityid) Where MyEntity is the name of your entity's class, "MyEntityName" is the name of the entity, and myentityid will be the number Minecraft uses to identify the mob. You can get a unique, unused entity id by calling EntityRegistry.findGlobalUniqueEntityId() instead of myentityid. A tutorial here (http://www.minecraftforum.net/topic/1417041-mod-entity-problem/page__st__140#entry18822284) says to only use registerModEntity(). It says: There is only one method for registering and adding tracking. EntityRegistry.registerModEntity(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates) : void At tutorial here (http://www.minecraftforum.net/topic/2389683-172-forge-add-new-block-item-entity-ai-creative-tab-language-localization-block-textures-side-textures/) says to use both methods, but to use the same entityID for both. It says: EntityRegistry.registerGlobalEntityID(entityClass, name, entityID); EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 1, true); EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor)); A message here (http://www.minecraftforum.net/topic/2564566-172spawning-my-entity-on-top-of-another-one-crashes-game/)indicates to use both methods, but use different ID in each: You also need to register your entity as a mod entity, using a mod-specific id. I do so using a static int modEntityIndex that I just iterate each time, and a custom helper method that I use for entities that have spawn eggs: public static void registerEntity(Class entityClass, String name, int primaryColor, int secondaryColor) { int id = EntityRegistry.findGlobalUniqueEntityId(); EntityRegistry.registerGlobalEntityID(entityClass, name, id, primaryColor, secondaryColor); EntityRegistry.registerModEntity(entityClass, name, ++modEntityIndex, ZSSMain.instance, 80, 3, false); } So which way is correct? The weird thing is they all kinda work -- I tried all three and can spawn the entities -- but I assume there is some invisible bad stuff going on if you do it the wrong way. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Jacknoshima Posted April 14, 2014 Posted April 14, 2014 Well, the first one is marked as outdated, so I'd ignore that. It looks to be 1.6 or 1.5, but could be earlier. Second one is 1.4 so DEFINITELY ignore that Third one looks right to me Fourth... couldn't really be bothered looking through that one all that much tbh, but it seemed more focused on other things and wasn't exactly a tutorial Quote
MrArcane111 Posted April 14, 2014 Posted April 14, 2014 An example from my WIP mod: EntityRegistry.registerGlobalEntityID(EntityBullet.class, "Bullet", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityBullet.class, "Bullet", Config.entBulletId, Steamcraft.instance, 64, 20, true); If you don't know what each of the values do in the registerModEntity, please read the Forge javadocs. Quote
jabelar Posted April 14, 2014 Author Posted April 14, 2014 An example from my WIP mod: EntityRegistry.registerGlobalEntityID(EntityBullet.class, "Bullet", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerModEntity(EntityBullet.class, "Bullet", Config.entBulletId, Steamcraft.instance, 64, 20, true); If you don't know what each of the values do in the registerModEntity, please read the Forge javadocs. Thanks. That is in line with case #4 (use both but different ID numbers). I do know about the parameters (distance to render, frequency of updates, velocity updates). @Jacknoshima Fourth... couldn't really be bothered looking through that one all that much tbh, but it seemed more focused on other things and wasn't exactly a tutorial You didn't have to look at the link because I quoted the specific advice. Note that the advice was from CoolAlias who I greatly respect. The key difference is that the id is different in the two registrations. In particular this meshes with the explanation in the second link that indicates that the mod entity registry is meant to be unique id within your mod -- doesn't need to be globally unique. I think method 4 (CoolAlias' suggestion, and backed up by McArcane) is technically correct, but 3 happens to work because if your global id is unique then your mob entity id will be unique too so no real problem created. It looks to be 1.6 or 1.5, but could be earlier. Second one is 1.4 so DEFINITELY ignore that I can't quite ignore these because even though they are older they each have a registration method that is different, and now we're supposed to use both? I understand if there is a newer method that replaces an older one, but it seems strange to me that the new method would be to combine both older methods. Also, the explanation in the second link is quite interesting and makes sense to me -- that the mod id is meant to get away from the trouble of the mod programmer worrying about globally unique id. While there is a method to find a globally unique id, there is another limitation with the global entity list related to it being limited to 255 entities (due to a byte cast on the id in the packets). If I look at the related mob spawn packet methods in 1.7.2 there is still a byte cast, so seems like that limitation is still present. Lastly, the weird thing to me is that ALL these methods kinda work when I try them. I tried all the scenarios, and in every case the entities are created, spawn, act on their AI, have NBT and restore from saves, etc. I would understand it better if skipping either of the registries prevented the spawn, since then it would imply that you need them. Just strange that it is hard to notice any difference in behavior between the cases. I guess I'll do some experiments to figure out what behavior is explicitly enabled by each registry. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
coolAlias Posted April 14, 2014 Posted April 14, 2014 Hi again, This issue was quite confusing to me as well, to be honest. In fact, I was under the impression that global entity IDs were not supposed to be used at all, and only to use registerModEntity. registerModEntity can take any ID, as the IDs are associated with your mod specifically, so I just start at zero and iterate up. This is what is used to track your entity. All mod entities should be registered this way, including projectiles, mobs, item entities, etc. Global entity ID is only necessary when registering an entity with a spawn egg, and needs to get a unique global entity ID from the EntityRegistry, otherwise your spawn eggs may conflict with those added by other mods. So if your entity is going to have a spawn egg, you need to register it globally, in addition to the registerModEntity. That's at least how I've come to understand it after working with it some, but the issue is far from 100% clear even after looking through Forge and what little documentation is available. If anyone who knows with absolute certainty can corroborate or correct my experiences, that would be wonderful. Cheers, coolAlias Quote http://i.imgur.com/NdrFdld.png[/img]
GotoLink Posted April 14, 2014 Posted April 14, 2014 You don't need to have a global entity id at all. The #registerModEntity is the right one. Also, the explanation in the second link is quite interesting and makes sense to me -- that the mod id is meant to get away from the trouble of the mod programmer worrying about globally unique id. While there is a method to find a globally unique id, there is another limitation with the global entity list related to it being limited to 255 entities (due to a byte cast on the id in the packets). If I look at the related mob spawn packet methods in 1.7.2 there is still a byte cast, so seems like that limitation is still present. This is totally correct. Also, while it doesn't give you a vanilla egg, it doesn't stop you from making one. The lazy step would be to register a global entity id and add it to the vanilla egg list. (but then the local id registration is far less interesting) Another solution is to create your own egg, like any item (see ItemMonsterPlacer, though you'll need to replace the global entity id lookup with either entity name or local id). Another solution is to use events and spawn the entity yourself. Quote
jabelar Posted April 14, 2014 Author Posted April 14, 2014 You don't need to have a global entity id at all. The #registerModEntity is the right one. Also, the explanation in the second link is quite interesting and makes sense to me -- that the mod id is meant to get away from the trouble of the mod programmer worrying about globally unique id. While there is a method to find a globally unique id, there is another limitation with the global entity list related to it being limited to 255 entities (due to a byte cast on the id in the packets). If I look at the related mob spawn packet methods in 1.7.2 there is still a byte cast, so seems like that limitation is still present. This is totally correct. Also, while it doesn't give you a vanilla egg, it doesn't stop you from making one. The lazy step would be to register a global entity id and add it to the vanilla egg list. (but then the local id registration is far less interesting) Another solution is to create your own egg, like any item (see ItemMonsterPlacer, though you'll need to replace the global entity id lookup with either entity name or local id). Another solution is to use events and spawn the entity yourself. I've been experimenting and like you and CoolAlias said it seems that vanilla eggs definitely require a globalID. I like the idea of only worrying about mod-specific ID since it seems like better programming practice. But in addition to not having spawn eggs (I wouldn't mind making my own if that was only thing), it seems that the natural spawn registrations also use globalID. So you'd have to make new natural spawning methods too? Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
SanAndreaP Posted April 14, 2014 Posted April 14, 2014 But in addition to not having spawn eggs (I wouldn't mind making my own if that was only thing), it seems that the natural spawn registrations also use globalID. So you'd have to make new natural spawning methods too? No. Entities are registered always within the EntityList. The registerModEntity just ignores the IDtoClassMapping and the classToIDMapping. Natural spawns always grab the entities from the class supplied by the EntityRegistry.addSpawn method. Quote Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! | mah twitter This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.
jabelar Posted April 15, 2014 Author Posted April 15, 2014 No. Entities are registered always within the EntityList. The registerModEntity just ignores the IDtoClassMapping and the classToIDMapping. But something is wrong because I don't see the modEntityID registrations ever show up in EntityList. I created a method to print out the EntityList after I registerEntities and it doesn't show any entries for my entities. Here is the EntityList after my registration (none of my entities are listed): Entity ID: 1 is Item Entity ID: 2 is XPOrb Entity ID: 3 is null Entity ID: 4 is null Entity ID: 5 is null Entity ID: 6 is null Entity ID: 7 is null Entity ID: 8 is LeashKnot Entity ID: 9 is Painting Entity ID: 10 is Arrow Entity ID: 11 is Snowball Entity ID: 12 is Fireball Entity ID: 13 is SmallFireball Entity ID: 14 is ThrownEnderpearl Entity ID: 15 is EyeOfEnderSignal Entity ID: 16 is ThrownPotion Entity ID: 17 is ThrownExpBottle Entity ID: 18 is ItemFrame Entity ID: 19 is WitherSkull Entity ID: 20 is PrimedTnt Entity ID: 21 is FallingSand Entity ID: 22 is FireworksRocketEntity Entity ID: 23 is null Entity ID: 24 is null Entity ID: 25 is null Entity ID: 26 is null Entity ID: 27 is null Entity ID: 28 is null Entity ID: 29 is null Entity ID: 30 is null Entity ID: 31 is null Entity ID: 32 is null Entity ID: 33 is null Entity ID: 34 is null Entity ID: 35 is null Entity ID: 36 is null Entity ID: 37 is null Entity ID: 38 is null Entity ID: 39 is null Entity ID: 40 is MinecartCommandBlock Entity ID: 41 is Boat Entity ID: 42 is MinecartRideable Entity ID: 43 is MinecartChest Entity ID: 44 is MinecartFurnace Entity ID: 45 is MinecartTNT Entity ID: 46 is MinecartHopper Entity ID: 47 is MinecartSpawner Entity ID: 48 is Mob Entity ID: 49 is Monster Entity ID: 50 is Creeper Entity ID: 51 is Skeleton Entity ID: 52 is Spider Entity ID: 53 is Giant Entity ID: 54 is Zombie Entity ID: 55 is Slime Entity ID: 56 is Ghast Entity ID: 57 is PigZombie Entity ID: 58 is Enderman Entity ID: 59 is CaveSpider Entity ID: 60 is Silverfish Entity ID: 61 is Blaze Entity ID: 62 is LavaSlime Entity ID: 63 is EnderDragon Entity ID: 64 is WitherBoss Entity ID: 65 is Bat Entity ID: 66 is Witch Entity ID: 67 is null Entity ID: 68 is null Entity ID: 69 is null Entity ID: 70 is null Entity ID: 71 is null Entity ID: 72 is null Entity ID: 73 is null Entity ID: 74 is null Entity ID: 75 is null Entity ID: 76 is null Entity ID: 77 is null Entity ID: 78 is null Entity ID: 79 is null Entity ID: 80 is null Entity ID: 81 is null Entity ID: 82 is null Entity ID: 83 is null Entity ID: 84 is null Entity ID: 85 is null Entity ID: 86 is null Entity ID: 87 is null Entity ID: 88 is null Entity ID: 89 is null Entity ID: 90 is Pig Entity ID: 91 is Sheep Entity ID: 92 is Cow Entity ID: 93 is Chicken Entity ID: 94 is Squid Entity ID: 95 is Wolf Entity ID: 96 is MushroomCow Entity ID: 97 is SnowMan Entity ID: 98 is Ozelot Entity ID: 99 is VillagerGolem Entity ID: 100 is EntityHorse Entity ID: 101 is null Entity ID: 102 is null Entity ID: 103 is null Entity ID: 104 is null Entity ID: 105 is null Entity ID: 106 is null Entity ID: 107 is null Entity ID: 108 is null Entity ID: 109 is null Entity ID: 110 is null Entity ID: 111 is null Entity ID: 112 is null Entity ID: 113 is null Entity ID: 114 is null Entity ID: 115 is null Entity ID: 116 is null Entity ID: 117 is null Entity ID: 118 is null Entity ID: 119 is null Entity ID: 120 is Villager Entity ID: 121 is null Entity ID: 122 is null Entity ID: 123 is null Entity ID: 124 is null Entity ID: 125 is null Entity ID: 126 is null Entity ID: 127 is null Entity ID: 128 is null Entity ID: 129 is null Entity ID: 130 is null Entity ID: 131 is null Entity ID: 132 is null Entity ID: 133 is null Entity ID: 134 is null Entity ID: 135 is null Entity ID: 136 is null Entity ID: 137 is null Entity ID: 138 is null Entity ID: 139 is null Entity ID: 140 is null Entity ID: 141 is null Entity ID: 142 is null Entity ID: 143 is null Entity ID: 144 is null Entity ID: 145 is null Entity ID: 146 is null Entity ID: 147 is null Entity ID: 148 is null Entity ID: 149 is null Entity ID: 150 is null Entity ID: 151 is null Entity ID: 152 is null Entity ID: 153 is null Entity ID: 154 is null Entity ID: 155 is null Entity ID: 156 is null Entity ID: 157 is null Entity ID: 158 is null Entity ID: 159 is null Entity ID: 160 is null Entity ID: 161 is null Entity ID: 162 is null Entity ID: 163 is null Entity ID: 164 is null Entity ID: 165 is null Entity ID: 166 is null Entity ID: 167 is null Entity ID: 168 is null Entity ID: 169 is null Entity ID: 170 is null Entity ID: 171 is null Entity ID: 172 is null Entity ID: 173 is null Entity ID: 174 is null Entity ID: 175 is null Entity ID: 176 is null Entity ID: 177 is null Entity ID: 178 is null Entity ID: 179 is null Entity ID: 180 is null Entity ID: 181 is null Entity ID: 182 is null Entity ID: 183 is null Entity ID: 184 is null Entity ID: 185 is null Entity ID: 186 is null Entity ID: 187 is null Entity ID: 188 is null Entity ID: 189 is null Entity ID: 190 is null Entity ID: 191 is null Entity ID: 192 is null Entity ID: 193 is null Entity ID: 194 is null Entity ID: 195 is null Entity ID: 196 is null Entity ID: 197 is null Entity ID: 198 is null Entity ID: 199 is null Entity ID: 200 is EnderCrystal Entity ID: 201 is null Entity ID: 202 is null Entity ID: 203 is null Entity ID: 204 is null Entity ID: 205 is null Entity ID: 206 is null Entity ID: 207 is null Entity ID: 208 is null Entity ID: 209 is null Entity ID: 210 is null Entity ID: 211 is null Entity ID: 212 is null Entity ID: 213 is null Entity ID: 214 is null Entity ID: 215 is null Entity ID: 216 is null Entity ID: 217 is null Entity ID: 218 is null Entity ID: 219 is null Entity ID: 220 is null Entity ID: 221 is null Entity ID: 222 is null Entity ID: 223 is null Entity ID: 224 is null Entity ID: 225 is null Entity ID: 226 is null Entity ID: 227 is null Entity ID: 228 is null Entity ID: 229 is null Entity ID: 230 is null Entity ID: 231 is null Entity ID: 232 is null Entity ID: 233 is null Entity ID: 234 is null Entity ID: 235 is null Entity ID: 236 is null Entity ID: 237 is null Entity ID: 238 is null Entity ID: 239 is null Entity ID: 240 is null Entity ID: 241 is null Entity ID: 242 is null Entity ID: 243 is null Entity ID: 244 is null Entity ID: 245 is null Entity ID: 246 is null Entity ID: 247 is null Entity ID: 248 is null Entity ID: 249 is null Entity ID: 250 is null Entity ID: 251 is null Entity ID: 252 is null Entity ID: 253 is null Entity ID: 254 is null Entity ID: 255 is null And here is my code for the registration. Main class preInit(): @EventHandler // preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the GameRegistry." public void preInit(FMLPreInitializationEvent event) { proxy.preInit(); reportEntityList(); // check list after registration } And my commonProxy class: package wildanimals.proxy; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.MinecraftForge; import wildanimals.WildAnimals; import wildanimals.WildAnimalsEventHandler; import wildanimals.WildAnimalsFMLEventHandler; import wildanimals.WildAnimalsOreGenEventHandler; import wildanimals.WildAnimalsTerrainGenEventHandler; import wildanimals.entities.bigcats.EntityJaguar; import wildanimals.entities.bigcats.EntityLion; import wildanimals.entities.bigcats.EntityLynx; import wildanimals.entities.bigcats.EntityManEatingTiger; import wildanimals.entities.bigcats.EntityTiger; import wildanimals.entities.herdanimals.EntityElephant; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.registry.EntityRegistry; public class CommonProxy { public int modEntityIndex ; public int spawnEggIndex ; public void preInit() { registerBlocks(); registerItems(); registerTileEntities(); registerRecipes(); registerEntities(); registerEntitySpawns(); registerFuelHandlers(); } public void load() { // register custom event listeners registerEventListeners(); } public void postInit() { // can do some inter-mod stuff here } // register blocks public void registerBlocks() { //example: GameRegistry.registerBlock(blockTomato, "tomatoes"); } // register items private void registerItems() { //example: GameRegistry.registerItem(tomato, "tomato"); // example: GameRegistry.registerCustomItemStack(name, itemStack); } // register tileentities public void registerTileEntities() { // example: GameRegistry.registerTileEntity(TileEntityStove.class, "stove_tile_entity"); } // register recipes public void registerRecipes() { // examples: // GameRegistry.addRecipe(recipe); // GameRegistry.addShapedRecipe(output, params); // GameRegistry.addShapelessRecipe(output, params); // GameRegistry.addSmelting(input, output, xp); } // register entities // lots of conflicting tutorials on this, currently following: http://www.minecraftforum.net/topic/2389683-172-forge-add-new-block-item-entity-ai-creative-tab-language-localization-block-textures-side-textures/ // another tut says to only register mod id http://www.minecraftforum.net/topic/1417041-mod-entity-problem/page__st__140#entry18822284 // another tut says to only register global id like http://www.minecraftforge.net/wiki/How_to_register_a_mob_entity#Registering_an_Entity public void registerEntities() { // Big cats EntityRegistry.registerModEntity(EntityTiger.class, "tiger", ++modEntityIndex, WildAnimals.instance, 80, 3, false); EntityRegistry.registerModEntity(EntityManEatingTiger.class, "maneatingtiger", ++modEntityIndex, WildAnimals.instance, 80, 3, false); EntityRegistry.registerModEntity(EntityLion.class, "lion", ++modEntityIndex, WildAnimals.instance, 80, 3, false); EntityRegistry.registerModEntity(EntityLynx.class, "lynx", ++modEntityIndex, WildAnimals.instance, 80, 3, false); EntityRegistry.registerModEntity(EntityJaguar.class, "jaguar", ++modEntityIndex, WildAnimals.instance, 80, 3, false); // Herd animals EntityRegistry.registerModEntity(EntityElephant.class, "elephant", ++modEntityIndex, WildAnimals.instance, 80, 3, false); } public void registerEntitySpawns() { // register natural spawns for entities // EntityRegistry.addSpawn(MyEntity.class, spawnProbability, minSpawn, maxSpawn, enumCreatureType, [spawnBiome]); // See the constructor in BiomeGenBase.java to see the rarity of vanilla mobs; Sheep are probability 10 while Endermen are probability 1 // minSpawn and maxSpawn are about how groups of the entity spawn // enumCreatureType represents the "rules" Minecraft uses to determine spawning, based on creature type. By default, you have three choices: // EnumCreatureType.creature uses rules for animals: spawn everywhere it is light out. // EnumCreatureType.monster uses rules for monsters: spawn everywhere it is dark out. // EnumCreatureType.waterCreature uses rules for water creatures: spawn only in water. // [spawnBiome] is an optional parameter of type BiomeGenBase that limits the creature spawn to a single biome type. Without this parameter, it will spawn everywhere. // Big cats // savanna cats EntityRegistry.addSpawn(EntityLion.class, 6, 0, 5, EnumCreatureType.creature, BiomeGenBase.savanna); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLion.class, 6, 0, 5, EnumCreatureType.creature, BiomeGenBase.savannaPlateau); //change the values to vary the spawn rarity, biome, etc. // hill cats EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.birchForestHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.coldTaigaHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.desertHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.extremeHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.extremeHillsEdge); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.extremeHillsPlus); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.forestHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.iceMountains); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.megaTaigaHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.mesaPlateau); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.mesaPlateau_F); //change the values to vary the spawn rarity, biome, etc. // swamp cats EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.swampland); //change the values to vary the spawn rarity, biome, etc. // jungle cats EntityRegistry.addSpawn(EntityJaguar.class, 6, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungle); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityJaguar.class, 3, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungleHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityJaguar.class, 1, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungleEdge); //change the values to vary the spawn rarity, biome, etc. // Jaden didn't want tigers! EntityRegistry.addSpawn(EntityTiger.class, 1, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungle); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityManEatingTiger.class, 1, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungle); //change the values to vary the spawn rarity, biome, etc. // Herd animals // savanna herds EntityRegistry.addSpawn(EntityElephant.class, 10, 0, 1, EnumCreatureType.creature, BiomeGenBase.savanna); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityElephant.class, 10, 0, 1, EnumCreatureType.creature, BiomeGenBase.savannaPlateau); //change the values to vary the spawn rarity, biome, etc. } public void registerFuelHandlers() { // example: GameRegistry.registerFuelHandler(handler); } public void registerEventListeners() { MinecraftForge.EVENT_BUS.register(new WildAnimalsEventHandler()); MinecraftForge.TERRAIN_GEN_BUS.register(new WildAnimalsTerrainGenEventHandler());; MinecraftForge.ORE_GEN_BUS.register(new WildAnimalsOreGenEventHandler()); // some events, especially tick, is handled on FML bus FMLCommonHandler.instance().bus().register(new WildAnimalsFMLEventHandler()); } } However, if I change the CommonProxy to use globalID then I get the following EntityList readout that shows my entities nicely registered: Entity ID: 1 is Item Entity ID: 2 is XPOrb Entity ID: 3 is tiger Entity ID: 4 is maneatingtiger Entity ID: 5 is lion Entity ID: 6 is lynx Entity ID: 7 is jaguar Entity ID: 8 is LeashKnot Entity ID: 9 is Painting Entity ID: 10 is Arrow Entity ID: 11 is Snowball Entity ID: 12 is Fireball Entity ID: 13 is SmallFireball Entity ID: 14 is ThrownEnderpearl Entity ID: 15 is EyeOfEnderSignal Entity ID: 16 is ThrownPotion Entity ID: 17 is ThrownExpBottle Entity ID: 18 is ItemFrame Entity ID: 19 is WitherSkull Entity ID: 20 is PrimedTnt Entity ID: 21 is FallingSand Entity ID: 22 is FireworksRocketEntity Entity ID: 23 is elephant Entity ID: 24 is null Entity ID: 25 is null Entity ID: 26 is null Entity ID: 27 is null Entity ID: 28 is null Entity ID: 29 is null Entity ID: 30 is null Entity ID: 31 is null Entity ID: 32 is null Entity ID: 33 is null Entity ID: 34 is null Entity ID: 35 is null Entity ID: 36 is null Entity ID: 37 is null Entity ID: 38 is null Entity ID: 39 is null Entity ID: 40 is MinecartCommandBlock Entity ID: 41 is Boat Entity ID: 42 is MinecartRideable Entity ID: 43 is MinecartChest Entity ID: 44 is MinecartFurnace Entity ID: 45 is MinecartTNT Entity ID: 46 is MinecartHopper Entity ID: 47 is MinecartSpawner Entity ID: 48 is Mob Entity ID: 49 is Monster Entity ID: 50 is Creeper Entity ID: 51 is Skeleton Entity ID: 52 is Spider Entity ID: 53 is Giant Entity ID: 54 is Zombie Entity ID: 55 is Slime Entity ID: 56 is Ghast Entity ID: 57 is PigZombie Entity ID: 58 is Enderman Entity ID: 59 is CaveSpider Entity ID: 60 is Silverfish Entity ID: 61 is Blaze Entity ID: 62 is LavaSlime Entity ID: 63 is EnderDragon Entity ID: 64 is WitherBoss Entity ID: 65 is Bat Entity ID: 66 is Witch Entity ID: 67 is null Entity ID: 68 is null Entity ID: 69 is null Entity ID: 70 is null Entity ID: 71 is null Entity ID: 72 is null Entity ID: 73 is null Entity ID: 74 is null Entity ID: 75 is null Entity ID: 76 is null Entity ID: 77 is null Entity ID: 78 is null Entity ID: 79 is null Entity ID: 80 is null Entity ID: 81 is null Entity ID: 82 is null Entity ID: 83 is null Entity ID: 84 is null Entity ID: 85 is null Entity ID: 86 is null Entity ID: 87 is null Entity ID: 88 is null Entity ID: 89 is null Entity ID: 90 is Pig Entity ID: 91 is Sheep Entity ID: 92 is Cow Entity ID: 93 is Chicken Entity ID: 94 is Squid Entity ID: 95 is Wolf Entity ID: 96 is MushroomCow Entity ID: 97 is SnowMan Entity ID: 98 is Ozelot Entity ID: 99 is VillagerGolem Entity ID: 100 is EntityHorse Entity ID: 101 is null Entity ID: 102 is null Entity ID: 103 is null Entity ID: 104 is null Entity ID: 105 is null Entity ID: 106 is null Entity ID: 107 is null Entity ID: 108 is null Entity ID: 109 is null Entity ID: 110 is null Entity ID: 111 is null Entity ID: 112 is null Entity ID: 113 is null Entity ID: 114 is null Entity ID: 115 is null Entity ID: 116 is null Entity ID: 117 is null Entity ID: 118 is null Entity ID: 119 is null Entity ID: 120 is Villager Entity ID: 121 is null Entity ID: 122 is null Entity ID: 123 is null Entity ID: 124 is null Entity ID: 125 is null Entity ID: 126 is null Entity ID: 127 is null Entity ID: 128 is null Entity ID: 129 is null Entity ID: 130 is null Entity ID: 131 is null Entity ID: 132 is null Entity ID: 133 is null Entity ID: 134 is null Entity ID: 135 is null Entity ID: 136 is null Entity ID: 137 is null Entity ID: 138 is null Entity ID: 139 is null Entity ID: 140 is null Entity ID: 141 is null Entity ID: 142 is null Entity ID: 143 is null Entity ID: 144 is null Entity ID: 145 is null Entity ID: 146 is null Entity ID: 147 is null Entity ID: 148 is null Entity ID: 149 is null Entity ID: 150 is null Entity ID: 151 is null Entity ID: 152 is null Entity ID: 153 is null Entity ID: 154 is null Entity ID: 155 is null Entity ID: 156 is null Entity ID: 157 is null Entity ID: 158 is null Entity ID: 159 is null Entity ID: 160 is null Entity ID: 161 is null Entity ID: 162 is null Entity ID: 163 is null Entity ID: 164 is null Entity ID: 165 is null Entity ID: 166 is null Entity ID: 167 is null Entity ID: 168 is null Entity ID: 169 is null Entity ID: 170 is null Entity ID: 171 is null Entity ID: 172 is null Entity ID: 173 is null Entity ID: 174 is null Entity ID: 175 is null Entity ID: 176 is null Entity ID: 177 is null Entity ID: 178 is null Entity ID: 179 is null Entity ID: 180 is null Entity ID: 181 is null Entity ID: 182 is null Entity ID: 183 is null Entity ID: 184 is null Entity ID: 185 is null Entity ID: 186 is null Entity ID: 187 is null Entity ID: 188 is null Entity ID: 189 is null Entity ID: 190 is null Entity ID: 191 is null Entity ID: 192 is null Entity ID: 193 is null Entity ID: 194 is null Entity ID: 195 is null Entity ID: 196 is null Entity ID: 197 is null Entity ID: 198 is null Entity ID: 199 is null Entity ID: 200 is EnderCrystal Entity ID: 201 is null Entity ID: 202 is null Entity ID: 203 is null Entity ID: 204 is null Entity ID: 205 is null Entity ID: 206 is null Entity ID: 207 is null Entity ID: 208 is null Entity ID: 209 is null Entity ID: 210 is null Entity ID: 211 is null Entity ID: 212 is null Entity ID: 213 is null Entity ID: 214 is null Entity ID: 215 is null Entity ID: 216 is null Entity ID: 217 is null Entity ID: 218 is null Entity ID: 219 is null Entity ID: 220 is null Entity ID: 221 is null Entity ID: 222 is null Entity ID: 223 is null Entity ID: 224 is null Entity ID: 225 is null Entity ID: 226 is null Entity ID: 227 is null Entity ID: 228 is null Entity ID: 229 is null Entity ID: 230 is null Entity ID: 231 is null Entity ID: 232 is null Entity ID: 233 is null Entity ID: 234 is null Entity ID: 235 is null Entity ID: 236 is null Entity ID: 237 is null Entity ID: 238 is null Entity ID: 239 is null Entity ID: 240 is null Entity ID: 241 is null Entity ID: 242 is null Entity ID: 243 is null Entity ID: 244 is null Entity ID: 245 is null Entity ID: 246 is null Entity ID: 247 is null Entity ID: 248 is null Entity ID: 249 is null Entity ID: 250 is null Entity ID: 251 is null Entity ID: 252 is null Entity ID: 253 is null Entity ID: 254 is null Entity ID: 255 is null Where my CommonProxy was now: package wildanimals.proxy; import net.minecraft.entity.EnumCreatureType; import net.minecraft.world.biome.BiomeGenBase; import net.minecraftforge.common.MinecraftForge; import wildanimals.WildAnimalsEventHandler; import wildanimals.WildAnimalsFMLEventHandler; import wildanimals.WildAnimalsOreGenEventHandler; import wildanimals.WildAnimalsTerrainGenEventHandler; import wildanimals.entities.bigcats.EntityJaguar; import wildanimals.entities.bigcats.EntityLion; import wildanimals.entities.bigcats.EntityLynx; import wildanimals.entities.bigcats.EntityManEatingTiger; import wildanimals.entities.bigcats.EntityTiger; import wildanimals.entities.herdanimals.EntityElephant; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.registry.EntityRegistry; public class CommonProxy { public int modEntityIndex ; public int spawnEggIndex ; public void preInit() { registerBlocks(); registerItems(); registerTileEntities(); registerRecipes(); registerEntities(); registerEntitySpawns(); registerFuelHandlers(); } public void load() { // register custom event listeners registerEventListeners(); } public void postInit() { // can do some inter-mod stuff here } // register blocks public void registerBlocks() { //example: GameRegistry.registerBlock(blockTomato, "tomatoes"); } // register items private void registerItems() { //example: GameRegistry.registerItem(tomato, "tomato"); // example: GameRegistry.registerCustomItemStack(name, itemStack); } // register tileentities public void registerTileEntities() { // example: GameRegistry.registerTileEntity(TileEntityStove.class, "stove_tile_entity"); } // register recipes public void registerRecipes() { // examples: // GameRegistry.addRecipe(recipe); // GameRegistry.addShapedRecipe(output, params); // GameRegistry.addShapelessRecipe(output, params); // GameRegistry.addSmelting(input, output, xp); } // register entities // lots of conflicting tutorials on this, currently following: http://www.minecraftforum.net/topic/2389683-172-forge-add-new-block-item-entity-ai-creative-tab-language-localization-block-textures-side-textures/ // another tut says to only register mod id http://www.minecraftforum.net/topic/1417041-mod-entity-problem/page__st__140#entry18822284 // another tut says to only register global id like http://www.minecraftforge.net/wiki/How_to_register_a_mob_entity#Registering_an_Entity public void registerEntities() { // Big cats EntityRegistry.registerGlobalEntityID(EntityTiger.class, "tiger", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityManEatingTiger.class, "maneatingtiger", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityLion.class, "lion", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityLynx.class, "lynx", EntityRegistry.findGlobalUniqueEntityId()); EntityRegistry.registerGlobalEntityID(EntityJaguar.class, "jaguar", EntityRegistry.findGlobalUniqueEntityId()); // Herd animals EntityRegistry.registerGlobalEntityID(EntityElephant.class, "elephant", EntityRegistry.findGlobalUniqueEntityId()); } public void registerEntitySpawns() { // register natural spawns for entities // EntityRegistry.addSpawn(MyEntity.class, spawnProbability, minSpawn, maxSpawn, enumCreatureType, [spawnBiome]); // See the constructor in BiomeGenBase.java to see the rarity of vanilla mobs; Sheep are probability 10 while Endermen are probability 1 // minSpawn and maxSpawn are about how groups of the entity spawn // enumCreatureType represents the "rules" Minecraft uses to determine spawning, based on creature type. By default, you have three choices: // EnumCreatureType.creature uses rules for animals: spawn everywhere it is light out. // EnumCreatureType.monster uses rules for monsters: spawn everywhere it is dark out. // EnumCreatureType.waterCreature uses rules for water creatures: spawn only in water. // [spawnBiome] is an optional parameter of type BiomeGenBase that limits the creature spawn to a single biome type. Without this parameter, it will spawn everywhere. // Big cats // savanna cats EntityRegistry.addSpawn(EntityLion.class, 6, 0, 5, EnumCreatureType.creature, BiomeGenBase.savanna); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLion.class, 6, 0, 5, EnumCreatureType.creature, BiomeGenBase.savannaPlateau); //change the values to vary the spawn rarity, biome, etc. // hill cats EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.birchForestHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.coldTaigaHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.desertHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.extremeHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.extremeHillsEdge); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.extremeHillsPlus); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.forestHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.iceMountains); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.megaTaigaHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.mesaPlateau); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.mesaPlateau_F); //change the values to vary the spawn rarity, biome, etc. // swamp cats EntityRegistry.addSpawn(EntityLynx.class, 5, 0, 1, EnumCreatureType.creature, BiomeGenBase.swampland); //change the values to vary the spawn rarity, biome, etc. // jungle cats EntityRegistry.addSpawn(EntityJaguar.class, 6, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungle); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityJaguar.class, 3, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungleHills); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityJaguar.class, 1, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungleEdge); //change the values to vary the spawn rarity, biome, etc. // Jaden didn't want tigers! EntityRegistry.addSpawn(EntityTiger.class, 1, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungle); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityManEatingTiger.class, 1, 0, 1, EnumCreatureType.creature, BiomeGenBase.jungle); //change the values to vary the spawn rarity, biome, etc. // Herd animals // savanna herds EntityRegistry.addSpawn(EntityElephant.class, 10, 0, 1, EnumCreatureType.creature, BiomeGenBase.savanna); //change the values to vary the spawn rarity, biome, etc. EntityRegistry.addSpawn(EntityElephant.class, 10, 0, 1, EnumCreatureType.creature, BiomeGenBase.savannaPlateau); //change the values to vary the spawn rarity, biome, etc. } public void registerFuelHandlers() { // example: GameRegistry.registerFuelHandler(handler); } public void registerEventListeners() { MinecraftForge.EVENT_BUS.register(new WildAnimalsEventHandler()); MinecraftForge.TERRAIN_GEN_BUS.register(new WildAnimalsTerrainGenEventHandler());; MinecraftForge.ORE_GEN_BUS.register(new WildAnimalsOreGenEventHandler()); // some events, especially tick, is handled on FML bus FMLCommonHandler.instance().bus().register(new WildAnimalsFMLEventHandler()); } } So I really don't see the modEntityID registration adding my entities to the EntityList. Or does it do it at some other range beyond id = 255? Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
coolAlias Posted April 15, 2014 Posted April 15, 2014 registerModEntity doesn't add entities to the ID mapping in EntityList, but it does add them by name and class. The following is a snippet of the registration code: String entityModName = String.format("%s.%s", mc.getModId(), entityName); EntityList.classToStringMapping.put(entityClass, entityModName); EntityList.stringToClassMapping.put(entityModName, entityClass); If you print out the entity list using the string to class map, with "modid.entityName", you will surely see your entities. The ID to class mapping is only used by spawn eggs (which is why the mod entity index and global ID can be different). My question is why haven't either Mojang or Forge team altered the vanilla ID to class map to allow everyone to use the ItemMonsterPlacer? Sure, it may be lazy to not make our own, but it's also good coding practice to not reinvent the wheel. Why copy/paste when you should be able to use something directly, or even through inheritance? It just seems bizarre to be moving toward a modding API but leave something as widely used as this in such a state. Quote http://i.imgur.com/NdrFdld.png[/img]
jabelar Posted April 15, 2014 Author Posted April 15, 2014 Does the /summon command also rely on global ID? I didn't have luck in having it summon my custom entity registered with modEntity registration, but works fine with globalID registration. Quote Check out my tutorials here: http://jabelarminecraft.blogspot.com/
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.