use Folia world on Folia servers

This commit is contained in:
Axionize committed 2024-11-30 12:58:55 -05:00
1 parent 151eb58fb6
commit 6d1ab1acbe
2 files changed
+5 -1

No files matched your search

@@ -5,6 +5,9 @@ import com.github.retrooper.packetevents.manager.server.ServerVersion;
import com.github.retrooper.packetevents.protocol.player.User;
import com.github.retrooper.packetevents.protocol.world.BoundingBox;
import com.github.retrooper.packetevents.util.Vector3d;
import me.caseload.knockbacksync.Base;
import me.caseload.knockbacksync.Platform;
import me.caseload.knockbacksync.world.FoliaWorld;
import me.caseload.knockbacksync.world.PlatformWorld;
import me.caseload.knockbacksync.world.SpigotWorld;
import org.bukkit.Bukkit;
@@ -135,7 +138,7 @@ public class BukkitPlayer implements PlatformPlayer {
@Override
public PlatformWorld getWorld() {
return new SpigotWorld(bukkitPlayer.getWorld());
return Base.INSTANCE.getPlatform() == Platform.FOLIA ? new FoliaWorld(bukkitPlayer.getWorld()) : new SpigotWorld(bukkitPlayer.getWorld());
}
@Override
@@ -54,6 +54,7 @@ public class FoliaWorld extends SpigotWorld {
Location location = new Location(super.world, start.getX(), start.getY(), start.getZ());
CompletableFuture<RayTraceResult> future = new CompletableFuture<>();
// Yes this code is bad; I know it's bad. We did not design this plugin around Folia, too bad!
scheduler.execute(plugin, location, () -> {
// Existing 1.13+ code using world.rayTraceBlocks
Vector startVec = new Vector(start.getX(), start.getY(), start.getZ());