Explosion that does not break blocks.

Started by Fredzik on

Topic category: Advanced modding

Active 1 year ago
Joined Jun 2018
Points:
938

User statistics:

  • Modifications: 5
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 350
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
Active 1 year ago
Joined Jun 2018
Points:
938

User statistics:

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

Can anyone help? >:(

Active 9 months ago
Joined Jun 2019
Points:
2792

User statistics:

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

change that enum to Explosion.Mode.NONE

Active 1 year ago
Joined Jun 2018
Points:
938

User statistics:

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

Ok, thanks. I will try.

Active 1 year ago
Joined Jun 2018
Points:
938

User statistics:

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

It worked!

Active 3 years ago
Joined Mar 2020
Points:
1278

User statistics:

  • Modifications: 2
  • Forum topics: 10
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 1145
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 ;)

Active 1 year ago
Joined Jun 2018
Points:
938

User statistics:

  • Modifications: 5
  • Forum topics: 6
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 350
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 :)

Active 1 month ago
Joined Dec 2024
Points:
53

User statistics:

  • Modifications: 0
  • Forum topics: 2
  • Wiki pages: 0
  • MCreator plugins: 0
  • Comments: 5
if you want to make it break…
Sun, 01/26/2025 - 12:05

if you want to make it break blocks but don't wanna dig into the code, just set the source from NONE to mob/block/player