@EventHandler(priority = EventPriority.LOWEST) public void onChunkRegenerate(ChunkPopulateEvent event) { if (SpoutCraftChunk.replaceBukkitChunk(event.getChunk())) { // Update the reference to the chunk in the event try { Field chunk = ChunkEvent.class.getDeclaredField("chunk"); chunk.setAccessible(true); chunk.set( event, event .getChunk() .getWorld() .getChunkAt(event.getChunk().getX(), event.getChunk().getZ())); } catch (Exception e) { e.printStackTrace(); } SimpleChunkDataManager dm = (SimpleChunkDataManager) SpoutManager.getChunkDataManager(); // Clear custom block data from generated chunks if it exists dm.clearCustomBlockIds(event.getWorld(), event.getChunk().getX(), event.getChunk().getZ()); dm.clearCustomBlockData(event.getWorld(), event.getChunk().getX(), event.getChunk().getZ()); dm.loadChunk(event.getChunk()); } }
@EventHandler(priority = EventPriority.LOWEST) public void onChunkLoad(ChunkLoadEvent event) { if (SpoutCraftChunk.replaceBukkitChunk(event.getChunk())) { // Update the reference to the chunk in the event try { Field chunk = ChunkEvent.class.getDeclaredField("chunk"); chunk.setAccessible(true); chunk.set( event, event .getChunk() .getWorld() .getChunkAt(event.getChunk().getX(), event.getChunk().getZ())); } catch (Exception e) { e.printStackTrace(); } SimpleChunkDataManager dm = (SimpleChunkDataManager) SpoutManager.getChunkDataManager(); dm.loadChunk(event.getChunk()); } }