From 93495012fc6da9ee9b0e10326109aba7fd61c012 Mon Sep 17 00:00:00 2001 From: MidnightTale Date: Thu, 13 Apr 2023 11:36:49 +0700 Subject: [PATCH] still moving --- src/main/java/xyz/hynse/foliaflow/FoliaFlow.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java index 5162083..9b89141 100644 --- a/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java +++ b/src/main/java/xyz/hynse/foliaflow/FoliaFlow.java @@ -37,16 +37,19 @@ public class FoliaFlow extends JavaPlugin implements Listener { for (World world : Bukkit.getWorlds()) { for (Entity entity : world.getEntities()) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { - Location loc = entity.getLocation(); + FallingBlock fallingBlock = (FallingBlock) entity; + Location loc = fallingBlock.getLocation(); debug("Falling block spawned at location " + loc); // Set the initial velocity of the falling block int index = counter % 4; counter++; Vector velocity = velocities[index]; - entity.setVelocity(velocity); - // Remove the block from the movingBlocks set after a delay, to prevent it from being immediately moved again - getServer().getScheduler().runTaskLater(this, () -> movingBlocks.remove(loc.getBlock().getLocation()), 20L); + fallingBlock.setVelocity(velocity); + + // Add the location to the set of moving blocks + movingBlocks.add(loc); + } } }