Explosion that does not break blocks.

Started by Fredzik on

Topic category: Advanced modding

Last seen on 12:59, 27. Nov 2023
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Explosion that does not break blocks.
Fri, 06/26/2020 - 10:46 (edited)

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
Last seen on 12:59, 27. Nov 2023
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can anyone help? >:(
Fri, 06/26/2020 - 10:56

Can anyone help? >:(

Last seen on 03:10, 19. Feb 2022
Joined Jun 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
change that enum to…
Fri, 06/26/2020 - 11:38

change that enum to Explosion.Mode.NONE

Last seen on 12:59, 27. Nov 2023
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Ok, thanks. I will try.
Fri, 06/26/2020 - 12:04

Ok, thanks. I will try.

Last seen on 12:59, 27. Nov 2023
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It worked!
Fri, 06/26/2020 - 12:24

It worked!

Last seen on 22:41, 29. Dec 2021
Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Or without coding you can do…
Fri, 06/26/2020 - 12:50

Or without coding you can do 0.3 explosion power, but that works to ;)

Last seen on 12:59, 27. Nov 2023
Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I tried lower explosion…
Fri, 06/26/2020 - 14:23

I tried lower explosion power but it was too low, so I decided to dig in the code and the result is positive :)