From 23f2930aaddf7e55e8d79765df516631ad048be8 Mon Sep 17 00:00:00 2001 From: Wyatt Childers Date: Tue, 22 Mar 2016 00:45:54 -0400 Subject: [PATCH] Removed the regeneration code for the Sponge platform --- .../worldedit/sponge/SpongeNMSWorld.java | 106 ------------------ .../sk89q/worldedit/sponge/SpongeWorld.java | 6 + 2 files changed, 6 insertions(+), 106 deletions(-) diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeNMSWorld.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeNMSWorld.java index 2a2a04ac8..ecdfc8677 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeNMSWorld.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeNMSWorld.java @@ -121,112 +121,6 @@ public class SpongeNMSWorld extends SpongeWorld { return false; } - private static K getFieldValue(Class clazz, T object, String feildName, Class valueClazz) { - try { - Field field = clazz.getDeclaredField(feildName); // Found in the MCP Mappings - field.setAccessible(true); - - return valueClazz.cast(field.get(object)); - } catch (NoSuchFieldException | IllegalAccessException e) { - System.out.println("Exception while modifying inaccessible variable: " + e.getMessage()); - } - throw new IllegalStateException("Invalid variable state"); - } - - @SuppressWarnings("unchecked") - @Override - public boolean regenerate(Region region, EditSession editSession) { - BaseBlock[] history = new BaseBlock[256 * (getMaxY() + 1)]; - - IChunkProvider provider = ((net.minecraft.world.World) getWorld()).getChunkProvider(); - if (!(provider instanceof ChunkProviderServer)) { - return false; - } - ChunkProviderServer chunkServer = (ChunkProviderServer) provider; - - IChunkProvider chunkProvider = getFieldValue( - ChunkProviderServer.class, - chunkServer, - "field_73246_d", // serverChunkGenerator - IChunkProvider.class - ); - - Set droppedChunksSet = getFieldValue( - ChunkProviderServer.class, - chunkServer, - "field_73248_b", // droppedChunksSet, - Set.class - ); - - LongHashMap id2ChunkMap = getFieldValue( - ChunkProviderServer.class, - chunkServer, - "field_73244_f", // id2ChunkMap - LongHashMap.class - ); - - List loadedChunks = getFieldValue( - ChunkProviderServer.class, - chunkServer, - "field_73245_g", // loadedChunks - List.class - ); - - for (Vector2D chunk : region.getChunks()) { - Vector min = new Vector(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16); - - for (int x = 0; x < 16; x++) { - for (int y = 0; y < getMaxY() + 1; y++) { - for (int z = 0; z < 16; z++) { - Vector pt = min.add(x, y, z); - int index = y * 16 * 16 + z * 16 + x; - history[index] = editSession.getBlock(pt); - } - } - } - try { - Set chunks = region.getChunks(); - for (Vector2D coord : chunks) { - long pos = ChunkCoordIntPair.chunkXZ2Int(coord.getBlockX(), coord.getBlockZ()); - Chunk mcChunk; - if (chunkServer.chunkExists(coord.getBlockX(), coord.getBlockZ())) { - mcChunk = chunkServer.loadChunk(coord.getBlockX(), coord.getBlockZ()); - mcChunk.onChunkUnload(); - } - droppedChunksSet.remove(pos); - id2ChunkMap.remove(pos); - mcChunk = chunkProvider.provideChunk(coord.getBlockX(), coord.getBlockZ()); - id2ChunkMap.add(pos, mcChunk); - loadedChunks.add(mcChunk); - if (mcChunk != null) { - mcChunk.onChunkLoad(); - mcChunk.populateChunk(chunkProvider, chunkProvider, coord.getBlockX(), coord.getBlockZ()); - } - } - } catch (Throwable t) { - logger.log(Level.WARNING, "Failed to generate chunk", t); - return false; - } - - for (int x = 0; x < 16; x++) { - for (int y = 0; y < getMaxY() + 1; y++) { - for (int z = 0; z < 16; z++) { - Vector pt = min.add(x, y, z); - int index = y * 16 * 16 + z * 16 + x; - - if (!region.contains(pt)) - editSession.smartSetBlock(pt, history[index]); - else { - editSession.rememberChange(pt, history[index], editSession.rawGetBlock(pt)); - } - } - } - } - } - - return false; - } - @Nullable private static WorldGenerator createWorldGenerator(TreeGenerator.TreeType type) { switch (type) { diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java index 353f74d5c..7518eb80f 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.sponge; import com.flowpowered.math.vector.Vector3d; import com.flowpowered.math.vector.Vector3i; import com.sk89q.jnbt.CompoundTag; +import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.WorldEditException; @@ -154,6 +155,11 @@ public abstract class SpongeWorld extends AbstractWorld { return true; } + @Override + public boolean regenerate(Region region, EditSession editSession) { + return false; + } + @Override public int getBlockLightLevel(Vector position) { checkNotNull(position);