Change spawn overworld falling block to above portal

This commit is contained in:
MidnightTale 2023-04-26 03:14:24 +07:00
commit 2369212335

View file

@ -128,29 +128,21 @@ public class FoliaFlow extends JavaPlugin implements Listener {
Location loc = entity.getLocation(); Location loc = entity.getLocation();
Vector vel = entity.getVelocity(); Vector vel = entity.getVelocity();
Block movingTo = getBlockMovingTo(loc, vel); Block movingTo = getBlockMovingTo(loc, vel);
try {
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){ if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
Location spawnLoc = movingTo.getLocation(); Location spawnLoc = movingTo.getLocation();
spawnLoc.setX(spawnLoc.getX()+0.5); spawnLoc.setX(spawnLoc.getX()+0.5);
spawnLoc.setY(spawnLoc.getY()-0.25); spawnLoc.setY(spawnLoc.getY()+0.5);
spawnLoc.setZ(spawnLoc.getZ()+0.5); spawnLoc.setZ(spawnLoc.getZ()+0.5);
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData()); FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
dummy.setDropItem(true);
dummy.setHurtEntities(true);
dummy.setGravity(true);
Vector dummyVel = vel.clone(); Vector dummyVel = vel.clone();
dummyVel.setY(-dummyVel.getY()); dummyVel.setY(-dummyVel.getY());
dummyVel.multiply(new Vector(2, 1, 2)); dummyVel.multiply(new Vector(2, 2, 2));
dummyVel.add(new Vector(0, -0.2, 0));
dummyVel.add(new Vector(0, 1, 0));
dummy.setVelocity(dummyVel); dummy.setVelocity(dummyVel);
} }
} catch (NullPointerException dummy) {
getServer().getLogger().info("onFallingBlockToBlock error (likely chunky it not load)");
}
} }
} }