|
13 | 13 | import org.bukkit.Material; |
14 | 14 | import org.bukkit.World; |
15 | 15 | import org.bukkit.craftbukkit.v1_13_R2.CraftWorld; |
| 16 | +import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock; |
16 | 17 | import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData; |
17 | 18 | import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer; |
18 | 19 | import org.bukkit.craftbukkit.v1_13_R2.util.CraftChatMessage; |
|
24 | 25 | import com.lishid.orebfuscator.nms.INmsManager; |
25 | 26 | import com.lishid.orebfuscator.types.BlockCoord; |
26 | 27 |
|
| 28 | +import java.lang.reflect.InvocationTargetException; |
| 29 | +import java.lang.reflect.Method; |
27 | 30 | import java.util.HashMap; |
28 | 31 | import java.util.HashSet; |
29 | 32 | import java.util.Set; |
@@ -427,7 +430,16 @@ public IChunkCache createChunkCache() { |
427 | 430 |
|
428 | 431 | public void updateBlockTileEntity(BlockCoord blockCoord, Player player) { |
429 | 432 | CraftWorld world = (CraftWorld)player.getWorld(); |
430 | | - TileEntity tileEntity = world.getTileEntityAt(blockCoord.x, blockCoord.y, blockCoord.z); |
| 433 | + // 1.13.2 has made this quite a bit different in later builds. |
| 434 | + TileEntity tileEntity = null; |
| 435 | + try { |
| 436 | + Method getTileEntityAt = world.getClass().getMethod("getTileEntityAt", int.class, int.class, int.class); |
| 437 | + tileEntity = (TileEntity) getTileEntityAt.invoke(world, blockCoord.x, blockCoord.y, blockCoord.z); |
| 438 | + } catch (NoSuchMethodException nsme) { |
| 439 | + tileEntity = world.getHandle().getTileEntity(new BlockPosition(blockCoord.x, blockCoord.y, blockCoord.z)); |
| 440 | + } catch (Exception e) { |
| 441 | + return; |
| 442 | + } |
431 | 443 |
|
432 | 444 | if (tileEntity == null) { |
433 | 445 | return; |
@@ -527,8 +539,23 @@ private static IBlockData getBlockData(World world, int x, int y, int z, boolean |
527 | 539 | int chunkZ = z >> 4; |
528 | 540 |
|
529 | 541 | WorldServer worldServer = ((CraftWorld)world).getHandle(); |
530 | | - ChunkProviderServer chunkProviderServer = worldServer.getChunkProviderServer(); |
531 | | - |
| 542 | + // like in ChunkCache, NMS change without R increment. |
| 543 | + ChunkProviderServer chunkProviderServer = null; |
| 544 | + try { |
| 545 | + Method getChunkProviderServer = worldServer.getClass().getDeclaredMethod("getChunkProviderServer"); |
| 546 | + chunkProviderServer = (ChunkProviderServer) getChunkProviderServer.invoke(worldServer); |
| 547 | + } catch (NoSuchMethodException nmfe) { |
| 548 | + try { |
| 549 | + Method getChunkProvider = worldServer.getClass().getDeclaredMethod("getChunkProvider"); |
| 550 | + chunkProviderServer = (ChunkProviderServer) getChunkProvider.invoke(worldServer); |
| 551 | + } catch (NoSuchMethodException nsme) { |
| 552 | + return null; // oops |
| 553 | + } catch (Exception e) { |
| 554 | + return null; |
| 555 | + } |
| 556 | + } catch (Exception e) { |
| 557 | + return null; |
| 558 | + } |
532 | 559 | if(!loadChunk && !chunkProviderServer.isLoaded(chunkX, chunkZ)) return null; |
533 | 560 |
|
534 | 561 | Chunk chunk = chunkProviderServer.getChunkAt(chunkX, chunkZ, true, true); |
|
0 commit comments