Started by
Fredzik
on
Topic category: Advanced modding
Hi! I made a grenade, but wanted to make the explosion caused but this item don't break any blocks. I lurked into the code of procedure "on bullet hits block/entity". In this procedure I used task "explode with power <?> at xyz". Here I found this: Explosion.Mode.BREAK); That was a signal to me I can make explosion that won't break blocks. Can anyone help me, what should I write instead of "BREAK" in the code part? Here's full code:
package net.mcreator.expandedmonsters.procedures;
import net.minecraft.world.World;
import net.minecraft.world.Explosion;
import net.mcreator.expandedmonsters.ExpandedMonstersModElements;
@ExpandedMonstersModElements.ModElement.Tag
public class CreepnadeBulletHitsLivingEntityProcedure extends ExpandedMonstersModElements.ModElement {
public CreepnadeBulletHitsLivingEntityProcedure(ExpandedMonstersModElements instance) {
super(instance, 100);
}
public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
if (dependencies.get("x") == null) {
System.err.println("Failed to load dependency x for procedure CreepnadeBulletHitsLivingEntity!");
return;
}
if (dependencies.get("y") == null) {
System.err.println("Failed to load dependency y for procedure CreepnadeBulletHitsLivingEntity!");
return;
}
if (dependencies.get("z") == null) {
System.err.println("Failed to load dependency z for procedure CreepnadeBulletHitsLivingEntity!");
return;
}
if (dependencies.get("world") == null) {
System.err.println("Failed to load dependency world for procedure CreepnadeBulletHitsLivingEntity!");
return;
}
int x = (int) dependencies.get("x");
int y = (int) dependencies.get("y");
int z = (int) dependencies.get("z");
World world = (World) dependencies.get("world");
if (!world.isRemote) {
world.createExplosion(null, (int) x, (int) y, (int) z, (float) 2, Explosion.Mode.BREAK);
}
}
}
Edited by Fredzik on Fri, 06/26/2020 - 10:46
Can anyone help? >:(
change that enum to Explosion.Mode.NONE
Ok, thanks. I will try.
It worked!
Or without coding you can do 0.3 explosion power, but that works to ;)
I tried lower explosion power but it was too low, so I decided to dig in the code and the result is positive :)