Fixing chunk issues

This commit is contained in:
Dawson
2023-03-25 14:03:06 -04:00
parent 66a4c9ec78
commit d4747897ad
6 changed files with 146 additions and 140 deletions
@@ -2,6 +2,7 @@ package dev.brighten.ac.utils.reflections.impl;
import dev.brighten.ac.utils.reflections.Reflections;
import dev.brighten.ac.utils.reflections.types.WrappedClass;
import dev.brighten.ac.utils.reflections.types.WrappedConstructor;
import dev.brighten.ac.utils.reflections.types.WrappedMethod;
import dev.brighten.ac.packet.ProtocolVersion;
import org.bukkit.Bukkit;
@@ -42,6 +43,9 @@ public class CraftReflection {
private static final WrappedMethod methodGetBlockFromMaterial = ProtocolVersion.getGameVersion()
.isOrAbove(ProtocolVersion.V1_13) ? craftMagicNumbers.getMethod("getBlock", Material.class)
: craftMagicNumbers.getMethod("getBlock", int.class);
private static final WrappedConstructor getBlockFromChunk = craftBlock
.getConstructor(craftChunk.getParent(), int.class, int.class, int.class);
private static WrappedMethod fromComponent;
public static <T> T getVanillaItemStack(ItemStack stack) {
@@ -97,6 +101,10 @@ public class CraftReflection {
return fromComponent.invoke(null, ichatcomp);
}
public static Block getBlockFromChunk(Chunk chunk, int x, int y, int z) {
return getBlockFromChunk.newInstance(chunk, x, y, z);
}
static {
if(ProtocolVersion.getGameVersion().isOrAbove(ProtocolVersion.V1_8)) {
fromComponent = craftChatMessage.getMethod("fromComponent",