Started by
davidS
on
Topic category: Help with Minecraft modding (Java Edition)
hello I want it to load like a bow and when I release it it explodes and does not harm the player
version 2020.3
google translate
Topic category: Help with Minecraft modding (Java Edition)
hello I want it to load like a bow and when I release it it explodes and does not harm the player
version 2020.3
google translate
you're asking two very different things in your title and post. what do you really want, for the explosion to not destroy blocks or not hurt the player?
both
to make explosion not destroy blocks, instead of using the "Explode at {x} {y} {z} with power {n}", use a Custom code snippet and in the text field enter: "if (!world.isRemote) {world.createExplosion(null, entity.posX, entity.posY, entity.posZ, (float) 5, false);}" and replace the 5 with the explosion power you desire. make sure that "world" is showing up in the Required Dependencies on the right side of the procedure page.
to make the explosion not hurt yourself, temporarily make yourself immune to damage. use Player procedure "Disable damage of [target entity] if [true] otherwise enable it" before the explosion and change the true to false after the explosion.
Where do I put the code you told me sorry for the inconvenience I do not know how to program
package net.mcreator.varius.procedures;
import net.minecraft.world.World;
import net.minecraft.world.Explosion;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.Entity;
import net.mcreator.varius.VariusModElements;
@VariusModElements.ModElement.Tag
public class MartillodediamanteRightClickedOnBlockProcedure extends VariusModElements.ModElement {
public MartillodediamanteRightClickedOnBlockProcedure(VariusModElements instance) {
super(instance, 33);
}
public static void executeProcedure(java.util.HashMap<String, Object> dependencies) {
if (dependencies.get("entity") == null) {
System.err.println("Failed to load dependency entity for procedure MartillodediamanteRightClickedOnBlock!");
return;
}
if (dependencies.get("x") == null) {
System.err.println("Failed to load dependency x for procedure MartillodediamanteRightClickedOnBlock!");
return;
}
if (dependencies.get("y") == null) {
System.err.println("Failed to load dependency y for procedure MartillodediamanteRightClickedOnBlock!");
return;
}
if (dependencies.get("z") == null) {
System.err.println("Failed to load dependency z for procedure MartillodediamanteRightClickedOnBlock!");
return;
}
if (dependencies.get("world") == null) {
System.err.println("Failed to load dependency world for procedure MartillodediamanteRightClickedOnBlock!");
return;
}
Entity entity = (Entity) dependencies.get("entity");
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 (entity instanceof PlayerEntity) {
((PlayerEntity) entity).abilities.disableDamage = (true);
((PlayerEntity) entity).sendPlayerAbilities();
}
if (!world.isRemote) {
world.createExplosion(null, (int) x, (int) y, (int) z, (float) 4, Explosion.Mode.BREAK);
}
if (entity instanceof PlayerEntity) {
((PlayerEntity) entity).abilities.disableDamage = (true);
((PlayerEntity) entity).sendPlayerAbilities();
}
if (entity instanceof PlayerEntity) {
((PlayerEntity) entity).abilities.disableDamage = (false);
((PlayerEntity) entity).sendPlayerAbilities();
}
}
}
enter this in the Custom code snippet text field:
it keeps failing to compile
this is from 3 years ago, the code may have changed(I'm not sure)