debug in excption

This commit is contained in:
MidnightTale 2023-04-11 20:24:49 +07:00
commit 3a924970a1

View file

@ -50,33 +50,23 @@ public class Bbsdfia extends JavaPlugin implements Listener {
Block movingTo = getBlockMovingTo(loc, vel); Block movingTo = getBlockMovingTo(loc, vel);
// If the block it's moving towards is an end portal block // If the block it's moving towards is an end portal block
if (movingTo != null && movingTo.getType() == Material.END_PORTAL) { if (movingTo != null && movingTo.getType() == Material.END_PORTAL) {
try {
// Spawn a new falling block entity in the end // Spawn a new falling block entity in the end
Location location = new Location(Bukkit.getWorld("world_the_end"), 100, 50, 0); World endWorld = Bukkit.getWorld("world_the_end");
System.out.println("§6[DEBUG] §7Spawning new falling block at " + location); World currentWorld = entity.getWorld();
System.out.println("§6[DEBUG] §7Original entity: " + entity); getLogger().info("Current world: " + currentWorld.getName());
System.out.println("§6[DEBUG] §7Moving towards: " + movingTo); getLogger().info("End world: " + endWorld.getName());
System.out.println("§6[DEBUG] §7Original velocity: " + vel); Location location = new Location(endWorld, loc.getX(), loc.getY(), loc.getZ());
FallingBlock fallingBlock = endWorld.spawnFallingBlock(location, ((FallingBlock) location.getWorld()).getBlockData());
FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(location, Material.STONE.createBlockData()); fallingBlock.setVelocity(vel);
System.out.println("§6[DEBUG] §7New falling block entity: " + fallingBlock); } catch (Exception ex) {
getLogger().severe("Error spawning falling block entity: " + ex.getMessage());
// Copy the velocity of the original entity and invert the y component ex.printStackTrace();
Vector dummyVel = vel.clone();
dummyVel.setY(-dummyVel.getY());
// Double the velocity of the new entity
dummyVel.multiply(new Vector(2, 2, 2));
// Add a constant upward velocity to simulate gravity
dummyVel.add(new Vector(0, 0.3, 0));
System.out.println("§6[DEBUG] §7Modified velocity: " + dummyVel);
// Set the velocity of the new entity to the modified velocity
fallingBlock.setVelocity(dummyVel);
} }
} }
} }
}
// This function returns the block that the entity is moving towards // This function returns the block that the entity is moving towards