From b4603a4b9a7f63297911ceecca16cdfe8b64df36 Mon Sep 17 00:00:00 2001 From: majikguy Date: Tue, 7 Mar 2017 19:17:18 -0500 Subject: [PATCH] Entity Registration Fix (#1087) * Replaced the Entity registration code. Before, the code was manually adding entities to the GameRegistry. Doing this prevents the engine from fully registering the added entities in all the proper places. The result was that the Client was never informed of when these entities were created or what they were doing, as all of that behavior is managed by the EntityRegistry. Changing to the proper EntityRegistry calls fixes issue #1065. * Changed ResourceLocation calls to the one with two arguments. Didn't know that was a thing before. :D Also added more consistent whitespace. --- .../bloodmagic/registry/ModEntities.java | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java b/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java index b7ff118d..acfa88d5 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModEntities.java @@ -1,6 +1,8 @@ package WayofTime.bloodmagic.registry; -import net.minecraftforge.fml.common.registry.EntityEntry; +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.api.Constants; +import net.minecraft.util.ResourceLocation; import WayofTime.bloodmagic.entity.mob.EntityCorruptedChicken; import WayofTime.bloodmagic.entity.mob.EntityCorruptedSheep; import WayofTime.bloodmagic.entity.mob.EntityCorruptedSpider; @@ -11,21 +13,22 @@ import WayofTime.bloodmagic.entity.projectile.EntityBloodLight; import WayofTime.bloodmagic.entity.projectile.EntityMeteor; import WayofTime.bloodmagic.entity.projectile.EntitySentientArrow; import WayofTime.bloodmagic.entity.projectile.EntitySoulSnare; -import net.minecraftforge.fml.common.registry.GameRegistry; +import net.minecraftforge.fml.common.registry.EntityRegistry; public class ModEntities { public static void init() { - GameRegistry.register(new EntityEntry(EntityBloodLight.class, "BloodLight").setRegistryName("BloodLight")); - GameRegistry.register(new EntityEntry(EntitySoulSnare.class, "SoulSnare").setRegistryName("SoulSnare")); - GameRegistry.register(new EntityEntry(EntitySentientArrow.class, "SoulArrow").setRegistryName("SoulArrow")); - GameRegistry.register(new EntityEntry(EntityMeteor.class, "Meteor").setRegistryName("Meteor")); - GameRegistry.register(new EntityEntry(EntitySentientSpecter.class, "SentientSpecter").setRegistryName("SentientSpecter")); - GameRegistry.register(new EntityEntry(EntityMimic.class, "Mimic").setRegistryName("Mimic")); - GameRegistry.register(new EntityEntry(EntityCorruptedZombie.class, "CorruptedZombie").setRegistryName("CorruptedZombie")); - GameRegistry.register(new EntityEntry(EntityCorruptedSheep.class, "CorruptedSheep").setRegistryName("CorruptedSheep")); - GameRegistry.register(new EntityEntry(EntityCorruptedChicken.class, "CorruptedChicken").setRegistryName("CorruptedChicken")); - GameRegistry.register(new EntityEntry(EntityCorruptedSpider.class, "CorruptedSpider").setRegistryName("CorruptedSpider")); + int entities = 0; + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "BloodLight"), EntityBloodLight.class, "BloodLight", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "SoulSnare"), EntitySoulSnare.class, "SoulSnare", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "SoulArrow"), EntitySentientArrow.class, "SoulArrow", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "Meteor"), EntityMeteor.class, "Meteor", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "SentientSpecter"), EntitySentientSpecter.class, "SentientSpecter", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "Mimic"), EntityMimic.class, "Mimic", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "CorruptedZombie"), EntityCorruptedZombie.class, "CorruptedZombie", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "CorruptedSheep"), EntityCorruptedSheep.class, "CorruptedSheep", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "CorruptedChicken"), EntityCorruptedChicken.class, "CorruptedChicken", ++entities, BloodMagic.instance, 16*4, 3, true); + EntityRegistry.registerModEntity(new ResourceLocation(Constants.Mod.MODID, "CorruptedSpider"), EntityCorruptedSpider.class, "CorruptedSpider", ++entities, BloodMagic.instance, 16*4, 3, true); } }