Jump to content

[1.7.10] Help removing baby and armored zombies.


Recommended Posts

Posted

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!  :)

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.