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!