Minecraft Blogs / Tutorial

[Request] How to Make A Mob Hatch When Block Broken [JAVA Coding] Modloader and Non-Modloader

  • 396 views, 2 today
  • 1
  • 1
  • 4
AlexxxRuler's Avatar AlexxxRuler
Level 42 : Master Ninja
39
People keep bugging me to make a website with tutorials. I will! Calm down.

WARNING! You will need to have at least begginer modding skills to code this.

STEP 1:
Register you're block like so:
[NAME] = (new Block[NAME](0, 0)).setHardness(0F)
.setStepSound(soundWhateverFootstep).setBlockName("[NAME]");

Where there is [NAME], place the name of your block. On Block[NAME], write what the name of your block's file is called, like for example: hatchBlock = (new BlockHatch(0, 0))...

STEP 2:
Make a block file for your block, and somewhere in it put in this line:

public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)

{
if(!world.multiplayerWorld)
{
Entity[MOB] entity[MOB] = new Entity[MOB](world);
entity[MOB] .setLocationAndAngles((double)i + 0.5D, j, (double)k + 0.5D, 0.0F, 0.0F);
world.entityJoinedWorld(entity[MOB] );
entity[MOB].spawnExplosionParticle();
}
super.onBlockDestroyedByPlayer(world, i, j, k, l);
}

When Entity[MOB], place the name of you're mobs file (like EntityZombie, EntityCreeper, etc.). When entity[MOB],
just write the name of the mob, but all lowercase (like if it was EntityZombe, write entityzombie).

If you did everything correctly, it should (on the block being broken) hatch a mob.

FINAL NOTE: This is NOT the entire code, this is what you add to you're code to make this ^ happen.

GOT ERRORS? Show me the error and you're code.
Tags

Create an account or sign in to comment.

1
02/07/2012 7:49 am
Level 21 : Expert Narwhal
Markuscraft
Markuscraft's Avatar
i see
1
02/07/2012 8:01 am
Level 42 : Master Ninja
AlexxxRuler
AlexxxRuler's Avatar
k :)
1
01/10/2012 3:59 am
Level 39 : Artisan Pixel Puncher
ASpArTa1n
ASpArTa1n's Avatar
It's so confusing! I dont under stand! yay!
1
01/10/2012 8:20 am
Level 42 : Master Ninja
AlexxxRuler
AlexxxRuler's Avatar
It's not really than confusing.
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome