Skip to content

Commit

Permalink
Merge pull request #238 from timderspieler/master
Browse files Browse the repository at this point in the history
Fix java.lang.invoke.WrongMethodTypeException:
  • Loading branch information
CryptoMorin authored Dec 24, 2023
2 parents 79db3a2 + b26957f commit dc23b5c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/main/java/com/cryptomorin/xseries/NMSExtras.java
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,23 @@ public static void chest(Block chest, boolean open) {
Location location = chest.getLocation();
try {
Object world = WORLD_HANDLE.invoke(location.getWorld());
Object position = BLOCK_POSITION.invoke(location.getX(), location.getY(), location.getZ());
Object position = v(19,
() ->
{
try {
return BLOCK_POSITION.invoke(location.getBlockX(), location.getBlockY(), location.getBlockZ());
} catch (Throwable e) {
throw new RuntimeException(e);
}
}).orElse(
() ->
{
try {
return BLOCK_POSITION.invoke(location.getX(), location.getY(), location.getZ());
} catch (Throwable e) {
throw new RuntimeException(e);
}
});
Object block = GET_BLOCK.invoke(GET_BLOCK_TYPE.invoke(world, position));
PLAY_BLOCK_ACTION.invoke(world, position, block, 1, open ? 1 : 0);
} catch (Throwable throwable) {
Expand Down

0 comments on commit dc23b5c

Please sign in to comment.