This commit is contained in:
MidnightTale 2023-04-24 22:14:47 +07:00
commit 8721778686

View file

@ -73,17 +73,25 @@ public class FoliaFlow extends JavaPlugin implements Listener {
public void onFallingBlockToBlockTheEnd(EntityChangeBlockEvent e) { public void onFallingBlockToBlockTheEnd(EntityChangeBlockEvent e) {
Entity entity = e.getEntity(); Entity entity = e.getEntity();
if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) { if (entity.getType() == EntityType.FALLING_BLOCK && entity.getWorld().getEnvironment() == World.Environment.THE_END) {
getLogger().info("found falling block main" + entity);
Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0); Location centerLoc = new Location(entity.getWorld(), 100, 48.5, 0);
Location loc = entity.getLocation(); Location loc = entity.getLocation();
if (loc.distance(centerLoc) <= 2) { if (loc.distance(centerLoc) <= 2) {
// Set the initial velocity of the falling block only if it doesn't have a velocity stored // Set the initial velocity of the falling block only if it doesn't have a velocity stored
if (!velocitiesMap.containsKey(entity)) { if (!velocitiesMap.containsKey(entity)) {
getLogger().info("add velocity falling block" + entity);
int index = counter % 4; int index = counter % 4;
getLogger().info("[1]" + entity);
counter++; counter++;
getLogger().info("[2]" + entity);
Vector velocity = velocities[index]; Vector velocity = velocities[index];
getLogger().info("[3]" + entity);
entity.setVelocity(velocity); entity.setVelocity(velocity);
getLogger().info("[4]" + entity);
velocitiesMap.put(entity, velocity); // Store the velocity in the map velocitiesMap.put(entity, velocity); // Store the velocity in the map
getLogger().info("[5]" + entity);
movingBlocks.add(entity.getLocation()); // Add the location to the set movingBlocks.add(entity.getLocation()); // Add the location to the set
getLogger().info("[6]" + entity);
} }
} }
} }