Exploding Fluid/Gas

Started by donmegel on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Exploding Fluid/Gas

I am trying to make a fluid that explodes when it touches a torch, or fire, etc. but am not having any luck. I created an IF THEN procedure that says if block at XYZ is a thing THEN explode but it isn't working.

Ideas?

Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
package mod.mcreator; …
Thu, 06/07/2018 - 22:37
package mod.mcreator;

import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;

import net.minecraft.world.World;
import net.minecraft.util.math.BlockPos;
import net.minecraft.item.ItemStack;
import net.minecraft.init.Blocks;

import java.util.Random;
import java.util.HashMap;

public class mcreator_mycoaldustexplode {

	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 mycoaldustexplode!");
			return;
		}
		if (dependencies.get("y") == null) {
			System.err.println("Failed to load dependency y for procedure mycoaldustexplode!");
			return;
		}
		if (dependencies.get("z") == null) {
			System.err.println("Failed to load dependency z for procedure mycoaldustexplode!");
			return;
		}
		if (dependencies.get("world") == null) {
			System.err.println("Failed to load dependency world for procedure mycoaldustexplode!");
			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.getBlockState(new BlockPos((int) x, (int) y, (int) z))).getBlock() == Blocks.BOOKSHELF.getDefaultState().getBlock())) {
			world.createExplosion(null, (int) x, (int) y, (int) z, (float) 4, true);
		}
	}

	public static Object instance;

	public void load(FMLInitializationEvent event) {
	}

	public void generateNether(World world, Random random, int chunkX, int chunkZ) {
	}

	public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
	}

	public void serverLoad(FMLServerStartingEvent event) {
	}

	public void preInit(FMLPreInitializationEvent event) {
	}

	public void registerRenderers() {
	}

	public int addFuel(ItemStack fuel) {
		return 0;
	}
}

 

Joined Jun 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Any ideas? This line sounds…
Fri, 06/08/2018 - 16:08

Any ideas? This line sounds bad:

System.err.println("Failed to load dependency x for procedure mycoaldustexplode!");

Joined May 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
That line only triggers if…
Mon, 06/11/2018 - 13:00

That line only triggers if it fails to load a dependency, as seen by the condition statement (if dependencies.get("x") == null), which means that if the dependency does not exist for whatever reason, then do what's in the code block. All of them have the condition statement for their particular dependency. The reason why you would want such a line is for debugging purposes in case something went horribly wrong.

Joined Jun 2016
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I can't code, but if you…
Tue, 06/12/2018 - 09:36

I can't code, but if you want to make a fluid explode when colliding another block, you shouldn't use x, y, z but a lot of conditions like x+1,y,z, x,y+1,z, x,y,z+1, x-1,y,z etc.

Sorry for bad English