Posted September 12, 201411 yr Hi folks, I want to make a mod where there are only zombies, not babies neither armored. Only normal "naked" adult zombies. I managed to cancel the spawning of all other mobs, and once I even made all babies grow with setChild(false), but once I started trying cancelling the spawn of the armored ones, nothing else works. I'm completely new to Java and modding, but not to programming. Here is my code (yes, started from the example, lol): It currently just lets zombies spawn (OK) but the babies and armored keeps coming, even if I setCanceled instead of trying to correct them. public class ExampleMod { public static final String MODID = "examplemod"; public static final String VERSION = "1.0"; @EventHandler public void init(FMLInitializationEvent event) { MinecraftForge.EVENT_BUS.register(new SpawnHandler()); } } public class SpawnHandler { @SubscribeEvent public void onEntitySpawn(EntityJoinWorldEvent event) { if( event.entity instanceof EntityMob ) { if ( !(event.entity instanceof EntityZombie) ) { event.setCanceled(true); } else { EntityZombie Mr_zombie = (EntityZombie) event.entity; if ( Mr_zombie.isChild() ) { Mr_zombie.setChild(false); } ItemStack itemstack = Mr_zombie.getEquipmentInSlot(4); if (itemstack != null) { Mr_zombie.setCurrentItemOrArmor(4, (ItemStack)null); } } } } } Help!
September 13, 201411 yr Author For those who might be interested, we came to a solution in this post on the minecraft forums: http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/modification-development/2212981-help-removing-baby-and-armored-zombies In short, "EntityJoinWorldEvent" happens BEFORE the spawn and before the function that set the age and armor of the zombies. For that reason we should remove the armor and set to adult on the "LivingSpawnEvent", which happens AFTER the zombie was already set up and spawned.
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.