How To Make Flying/Falling Blocks like Falling Sand

Started by ZipTheDev on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How To Make Flying/Falling Blocks like Falling Sand

mhm, i just wanna make a "bullet" with procedure like a: When Bullet Hits Block, Game Creating a Boom With Flying/Falling nearby Blocks.

Can You Help me?

Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You can make it with command
Sat, 10/31/2020 - 11:35

You can make it with command

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Well, I mean it can be done…
Sat, 10/31/2020 - 11:59

Well, I mean it can be done using commands, as seen in this video (https://www.youtube.com/watch?v=vYZ1nqk1jUE), but not easily... This video uses a single command to create a bunch of command blocks. Now, it is possible to run commands with MCreator, and if you knew all the commands you could just copy and paste them in. Unfortunately, the video I put is for 1.8, and the commands have changed since then. If you could find a video or command that does this in whatever version you want (I'll assume you want 1.15.2 for my search), I could decompile it for you and give you the commands.

Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I have made a procedure that…
Tue, 11/03/2020 - 20:02

I have made a procedure that does this. Unfortunately, it had to be coded directly in java and not through the blocky editor. Here's how you can get the procedure into your mod:

  1. Make a new procedure. Don't change anything about the procedure; just save it immediately.
  2. Go back to your workspace and click once on your new procedure. Then click on the button beneath the trash can under the green plus.
  3. That should open a code editor that looks something like the code below. The exact words will depend on what you called all the stuff, but that's not important. To get the code I wrote into your mod, follow the instructions after the //
  4. package net.mcreator.testingmod.procedures;
    
    import net.mcreator.testingmod.TestingModModElements;
    
    import java.util.Map;
    
    //step 5 code goes here
    
    @TestingModModElements.ModElement.Tag
    public class TestProcedure extends TestingModModElements.ModElement {
    	public TestProcedure(TestingModModElements instance) {
    		super(instance, 25);
    	}
        
        // delete this
    	public static void executeProcedure(Map<String, Object> dependencies) {
    	}
        // to here
        // step 6 code goes here
    }

     

  5. import net.minecraftforge.fml.server.ServerLifecycleHooks;
    import net.minecraftforge.eventbus.api.SubscribeEvent;
    import net.minecraftforge.event.world.ExplosionEvent;
    import net.minecraftforge.common.MinecraftForge;
    
    import net.minecraft.world.server.ServerWorld;
    import net.minecraft.world.World;
    import net.minecraft.world.IWorld;
    import net.minecraft.world.Explosion;
    import net.minecraft.util.text.StringTextComponent;
    import net.minecraft.server.MinecraftServer;
    import net.minecraft.util.math.BlockPos;
    import net.minecraft.command.ICommandSource;
    import net.minecraft.command.CommandSource;
    import net.minecraft.util.math.Vec3d;
    import net.minecraft.util.math.Vec2f;
    import net.minecraft.block.Blocks;
  6. public static void executeProcedure(Map<String, Object> dependencies, List<BlockPos> affected) {
    		if (dependencies.get("world") == null) {
    			System.err.println("Failed to load dependency world");
    			return;
    		}
    		if (dependencies.get("x") == null) {
    			System.err.println("Failed to load dependency x");
    			return;
    		}
    		if (dependencies.get("y") == null) {
    			System.err.println("Failed to load dependency y");
    			return;
    		}
    		if (dependencies.get("z") == null) {
    			System.err.println("Failed to load dependency z");
    			return;
    		}
    
    		IWorld world = (IWorld) dependencies.get("world");
    		String name = "";
    		double x = dependencies.get("x") instanceof Integer ? (int) dependencies.get("x") : (double) dependencies.get("x");
    		double y = dependencies.get("y") instanceof Integer ? (int) dependencies.get("y") : (double) dependencies.get("y");
    		double z = dependencies.get("z") instanceof Integer ? (int) dependencies.get("z") : (double) dependencies.get("z");
    		
    		for (int i = 0; i < affected.size(); i++) {
                BlockPos p = affected.get(i);
                
    			if (!world.isAirBlock(p) && (world.getBlockState(p)).getBlock() != Blocks.TNT.getDefaultState().getBlock()) {
    				name = "" + ((world.getBlockState(p)).getBlock());
    				name = name.substring(6, name.length() - 1);
    
    				
    				if (!world.getWorld().isRemote && world.getWorld().getServer() != null) {
    					world.getWorld().getServer().getCommandManager().handleCommand(
    							new CommandSource(ICommandSource.DUMMY, new Vec3d(p.getX(), p.getY(), p.getZ()), Vec2f.ZERO, (ServerWorld) world, 4, "",
    									new StringTextComponent(""), world.getWorld().getServer(), null).withFeedbackDisabled(),
    							(("summon minecraft:falling_block ~0.5 ~ ~0.5 {Time:1,CustomName:'{\"text\":\"Debris\"}',HurtEntities:1,Motion:[" + 
    							1/(p.getX()-x) + "d," + 1/(p.getY()-y) + "d," + 1/(p.getZ()-z) + "d],BlockState:{Name:\"")
    									+ "" + (name) + "" + ("\"}}")));
    				}
    				world.setBlockState(p, Blocks.AIR.getDefaultState(), 3);
    				
    			}
            }
    	}
    
    	@SubscribeEvent
    	public void onExplode(ExplosionEvent.Detonate event) {
    		List<BlockPos> affected = event.getAffectedBlocks();
    		World world = event.getWorld();
    		Explosion explosion = event.getExplosion();
    		int i = (int) explosion.getPosition().x;
    		int j = (int) explosion.getPosition().y;
    		int k = (int) explosion.getPosition().z;
    		Map<String, Object> dependencies = new HashMap<>();
    		dependencies.put("x", i);
    		dependencies.put("y", j);
    		dependencies.put("z", k);
    		dependencies.put("world", world);
    		dependencies.put("event", event);
    		this.executeProcedure(dependencies, affected);
    	}

Please ask if you didn't understand what I just put there or if you have any other problems :).

 

Joined Jun 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Willk55 if you are still…
Wed, 08/09/2023 - 20:50

Willk55 if you are still there, can you send an image of this code? i dont know what to delete