Vanilla parity fix on Folia

This commit is contained in:
Sofiane H. Djerbi 2023-04-26 14:24:29 +03:00
commit cfa36f99e5
2 changed files with 7 additions and 5 deletions

View file

@ -16,7 +16,7 @@ public class SchedulerUtil {
return false;
}
private static Boolean isFolia() {
public static Boolean isFolia() {
if (IS_FOLIA == null) IS_FOLIA = tryFolia();
return IS_FOLIA;
}

View file

@ -25,7 +25,7 @@ public class PortalWatcher implements Listener {
Vector vel = entity.getVelocity();
Block movingTo = getBlockMovingTo(loc, vel);
if(movingTo != null && movingTo.getType() == Material.END_PORTAL){
if(movingTo.getType() == Material.END_PORTAL){
Location spawnLoc = movingTo.getLocation();
spawnLoc.add(0.5, 0.5, 0.5);
@ -33,12 +33,14 @@ public class PortalWatcher implements Listener {
Vector dummyVel = vel.clone();
dummyVel.setY(-dummyVel.getY());
dummyVel.multiply(1.3); // This seems vanilla.
dummyVel.add(new Vector(0, -0.2, 0));
dummy.setVelocity(dummyVel);
// Add vector seems vanilla.
SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance,
() -> dummy.setVelocity(dummyVel.add(new Vector(0, 0.45, 0))),
SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> {
// Portal teleportation on Folia is a bit below vanilla, so we teleport it above
if (SchedulerUtil.isFolia()) dummy.teleportAsync(dummy.getLocation().add(0, 0.5, 0));
dummy.setVelocity(dummyVel);
},
2
);
}