Hello Minecraft PE modders I want to know if I can make a mod that creepers explode but don't destroy the terrain (Cinda like the command [/gamerule mobGreifing false]) if its possible to do this please post it on my tread OK am actually new to modding
Its pretty easy, but this method is a bit lame. But it works..
Since we can use preventDefault() in the hook function explodeHook, this is what we are gonna do
function explodeHook(entity, x, y, z, power, onFire) // the hook
{
if(Entity.getEntityTypeId(entity) == EntityType.CREEPER) // checks if the entity that exploded is a creeper
{
preventDefault(); // prevents the explosion. Note that this will also prevent the sound and particles to play/appear, so we are gonna use a little trick
Level.addParticle(ParticleType.hugeexplosion, x, y, z, 0, 0, 0); // creates the particle effects which will appear in explosion coordinates, with 0 velocities and uses default particle size
Level.playSoundEnt(entity, "random.explode", 100, 0); // plays the explosion sound where the creeper is
}
}
Hello Minecraft PE modders I want to know if I can make a mod that creepers explode but don't destroy the terrain (Cinda like the command [/gamerule mobGreifing false]) if its possible to do this please post it on my tread OK am actually new to modding
Its pretty easy, but this method is a bit lame. But it works..
Since we can use preventDefault() in the hook function explodeHook, this is what we are gonna do
function explodeHook(entity, x, y, z, power, onFire) // the hook { if(Entity.getEntityTypeId(entity) == EntityType.CREEPER) // checks if the entity that exploded is a creeper { preventDefault(); // prevents the explosion. Note that this will also prevent the sound and particles to play/appear, so we are gonna use a little trick Level.addParticle(ParticleType.hugeexplosion, x, y, z, 0, 0, 0); // creates the particle effects which will appear in explosion coordinates, with 0 velocities and uses default particle size Level.playSoundEnt(entity, "random.explode", 100, 0); // plays the explosion sound where the creeper is } }I hope this helps
I think you missed removing the mob. Aside from that, probably the best solution!
To Download my Mods, after you click the download link, select the arrow in the UPPER RIGHT. This will then, download the file to your device
Well, you dont actually need to remove the mob, since they are removed when they explode. I've tested it and it works..
Help's but can I make it harm entity
Since you stopped it from exploding, you will have to cause harm to the entities you need to cause harm to.
To Download my Mods, after you click the download link, select the arrow in the UPPER RIGHT. This will then, download the file to your device