net.minecraft.world.chunk.storage.AnvilChunkLoader Java Examples
The following examples show how to use
net.minecraft.world.chunk.storage.AnvilChunkLoader.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: QueuedChunk.java From Kettle with GNU General Public License v3.0 | 5 votes |
public QueuedChunk(int x, int z, AnvilChunkLoader loader, World world, ChunkProviderServer provider) { this.x = x; this.z = z; this.loader = loader; this.world = world; this.provider = provider; }
Example #2
Source File: ChunkIOProvider.java From Kettle with GNU General Public License v3.0 | 5 votes |
public Chunk callStage1(QueuedChunk queuedChunk) throws RuntimeException { try { AnvilChunkLoader loader = queuedChunk.loader; Object[] data = loader.loadChunk__Async(queuedChunk.world, queuedChunk.x, queuedChunk.z); if (data != null) { queuedChunk.compound = (NBTTagCompound) data[1]; return (Chunk) data[0]; } return null; } catch (IOException ex) { throw new RuntimeException(ex); } }
Example #3
Source File: ChunkIOExecutor.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static Chunk syncChunkLoad(World world, AnvilChunkLoader loader, ChunkProviderServer provider, int x, int z) { return instance.getSkipQueue(new QueuedChunk(x, z, loader, world, provider)); }
Example #4
Source File: ChunkIOExecutor.java From Kettle with GNU General Public License v3.0 | 4 votes |
public static void queueChunkLoad(World world, AnvilChunkLoader loader, ChunkProviderServer provider, int x, int z, Runnable runnable) { instance.add(new QueuedChunk(x, z, loader, world, provider), runnable); }
Example #5
Source File: ClientChunkSize.java From ForgeHax with MIT License | 4 votes |
@SubscribeEvent public void onTick(ClientTickEvent event) { if (getWorld() == null || getLocalPlayer() == null || running) { return; } switch (event.phase) { case END: { Chunk chunk = getWorld().getChunkFromBlockCoords(getLocalPlayer().getPosition()); if (chunk.isEmpty()) { return; } ChunkPos pos = chunk.getPos(); if (!pos.equals(current) || (timer.isStarted() && timer.hasTimeElapsed(1000L))) { // chunk changed, don't show diff between different chunks if (current != null && !pos.equals(current)) { size = previousSize = 0L; } current = pos; running = true; // process size calculation on another thread Executors.defaultThreadFactory() .newThread( () -> { try { final NBTTagCompound root = new NBTTagCompound(); NBTTagCompound level = new NBTTagCompound(); root.setTag("Level", level); root.setInteger("DataVersion", 1337); try { // this should be done on the main mc thread but it works 99% of the // time outside it AnvilChunkLoader loader = new AnvilChunkLoader(DUMMY, null); Methods.AnvilChunkLoader_writeChunkToNBT.invoke( loader, chunk, getWorld(), level); } catch (Throwable t) { size = -1L; previousSize = 0L; return; // couldn't save chunk } DataOutputStream compressed = new DataOutputStream( new BufferedOutputStream( new DeflaterOutputStream(new ByteArrayOutputStream(8096)))); try { CompressedStreamTools.write(root, compressed); previousSize = size; size = compressed.size(); } catch (IOException e) { size = -1L; previousSize = 0L; } } finally { timer.start(); running = false; } }) .start(); } break; } default: break; } }