Attempt #3 to fix getBlockStateAt() in Folia
This commit is contained in:
1 parent
a3b5999de3
commit
511c634c41
3 files changed
+24
-3
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.BukkitBase;
|
||||
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;
|
||||
@@ -33,7 +36,7 @@ public class BukkitPlayer implements PlatformPlayer {
|
||||
// 1.12.2 support
|
||||
static {
|
||||
try {
|
||||
// Check the current server versio
|
||||
// Check the current server version
|
||||
|
||||
// If the version is greater than 1.14.4, use the Player method directly
|
||||
if (currentVersion.isOlderThan(ServerVersion.V_1_15)) {
|
||||
@@ -135,7 +138,7 @@ public class BukkitPlayer implements PlatformPlayer {
|
||||
|
||||
@Override
|
||||
public PlatformWorld getWorld() {
|
||||
return new SpigotWorld(bukkitPlayer.getWorld());
|
||||
return BukkitBase.INSTANCE.getPlatform() == Platform.FOLIA ? new FoliaWorld(bukkitPlayer.getWorld()): new SpigotWorld(bukkitPlayer.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package me.caseload.knockbacksync.world;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.world.states.WrappedBlockState;
|
||||
import io.github.retrooper.packetevents.util.SpigotConversionUtil;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
public class FoliaWorld extends SpigotWorld {
|
||||
public FoliaWorld(World world) {
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WrappedBlockState getBlockStateAt(int x, int y, int z) {
|
||||
BlockState block = this.world.getBlockState(x, y, z);
|
||||
return SpigotConversionUtil.fromBukkitBlockData(block.getBlockData());
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import org.bukkit.util.Vector;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class SpigotWorld implements PlatformWorld {
|
||||
private final World world;
|
||||
protected final World world;
|
||||
|
||||
// Reflection variables
|
||||
private static Class<?> craftWorldClass;
|
||||
|
||||
Reference in new issue
Block a user