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.
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 |
tools/tracking
470109
6
request-how-to-make-a-mob-hatch-when-block-broken-java-coding-modloader-and-non-modloader
Create an account or sign in to comment.