mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 10:35:18 +01:00
Removed some illegal access reflection.
This commit is contained in:
parent
e0bed2d80e
commit
3d415d6da6
@ -309,7 +309,7 @@ public class BlockUtils {
|
||||
}
|
||||
|
||||
private static Class<?> clazzCraftWorld, clazzCraftBlock, clazzBlockPosition;
|
||||
private static Method getHandle, updateAdjacentComparators, getNMSBlock;
|
||||
private static Method getHandle, updateAdjacentComparators, craftBlock_getNMS, nmsBlockData_getBlock;
|
||||
|
||||
/**
|
||||
* Manually trigger the updateAdjacentComparators method for containers
|
||||
@ -331,8 +331,10 @@ public class BlockUtils {
|
||||
|
||||
getHandle = clazzCraftWorld.getMethod("getHandle");
|
||||
updateAdjacentComparators = clazzWorld.getMethod("updateAdjacentComparators", clazzBlockPosition, clazzBlock);
|
||||
getNMSBlock = clazzCraftBlock.getDeclaredMethod("getNMSBlock");
|
||||
getNMSBlock.setAccessible(true);
|
||||
|
||||
craftBlock_getNMS = clazzCraftBlock.getDeclaredMethod("getNMS");
|
||||
Class<?> clazzBlockData = Class.forName("net.minecraft.server." + ver + ".BlockBase$BlockData");
|
||||
nmsBlockData_getBlock = clazzBlockData.getDeclaredMethod("getBlock");
|
||||
}
|
||||
|
||||
// invoke and cast objects.
|
||||
@ -344,7 +346,7 @@ public class BlockUtils {
|
||||
updateAdjacentComparators
|
||||
.invoke(world, clazzBlockPosition.getConstructor(double.class, double.class, double.class)
|
||||
.newInstance(location.getX(), location.getY(), location.getZ()),
|
||||
getNMSBlock.invoke(craftBlock));
|
||||
nmsBlockData_getBlock.invoke(craftBlock_getNMS.invoke(craftBlock)));
|
||||
|
||||
} catch (ReflectiveOperationException e) {
|
||||
e.printStackTrace();
|
||||
|
@ -74,10 +74,13 @@ public class BlockUtilsModern {
|
||||
}
|
||||
}
|
||||
|
||||
private static Class<?> clazzCraftWorld, clazzCraftBlock,
|
||||
clazzLeverBlock, clazzButtonBlock, clazzPressurePlateBlock;
|
||||
private static Method craftWorld_getHandle, craftBlock_getNMSBlock, craftBlock_getPostition, craftBlockData_getState,
|
||||
nmsLever_updateNeighbours, nmsButton_updateNeighbours, nmsPlate_updateNeighbours;
|
||||
private static Class<?> clazzCraftWorld;
|
||||
private static Class<?> clazzCraftBlock;
|
||||
private static Class<?> clazzLeverBlock;
|
||||
private static Class<?> clazzButtonBlock;
|
||||
private static Class<?> clazzPressurePlateBlock;
|
||||
private static Method craftWorld_getHandle, craftBlock_getNMS, craftBlock_getPostition, craftBlockData_getState,
|
||||
nmsLever_updateNeighbours, nmsButton_updateNeighbours, nmsPlate_updateNeighbours, nmsBlockData_getBlock;
|
||||
|
||||
static {
|
||||
try {
|
||||
@ -89,10 +92,12 @@ public class BlockUtilsModern {
|
||||
//clazzBlockPosition = Class.forName("net.minecraft.server." + ver + ".BlockPosition");
|
||||
|
||||
craftWorld_getHandle = clazzCraftWorld.getMethod("getHandle");
|
||||
craftBlock_getNMSBlock = clazzCraftBlock.getDeclaredMethod("getNMSBlock");
|
||||
craftBlock_getNMSBlock.setAccessible(true);
|
||||
craftBlock_getPostition = clazzCraftBlock.getDeclaredMethod("getPosition");
|
||||
|
||||
craftBlock_getNMS = clazzCraftBlock.getDeclaredMethod("getNMS");
|
||||
Class<?> clazzBlockData = Class.forName("net.minecraft.server." + ver + ".BlockBase$BlockData");
|
||||
nmsBlockData_getBlock = clazzBlockData.getDeclaredMethod("getBlock");
|
||||
|
||||
Class<?> clazzCraftBlockData = Class.forName("org.bukkit.craftbukkit." + ver + ".block.data.CraftBlockData");
|
||||
craftBlockData_getState = clazzCraftBlockData.getDeclaredMethod("getState");
|
||||
|
||||
@ -131,7 +136,7 @@ public class BlockUtilsModern {
|
||||
Object cworld = clazzCraftWorld.cast(block.getWorld());
|
||||
Object mworld = craftWorld_getHandle.invoke(cworld);
|
||||
Object cblock = clazzCraftBlock.cast(block);
|
||||
Object mblock = craftBlock_getNMSBlock.invoke(cblock);
|
||||
Object mblock = nmsBlockData_getBlock.invoke(craftBlock_getNMS.invoke(cblock));
|
||||
Object mpos = craftBlock_getPostition.invoke(cblock);
|
||||
|
||||
//System.out.println(mblock.getClass());
|
||||
|
Loading…
Reference in New Issue
Block a user