diff --git a/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java b/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java index 54845d17..5fc76581 100644 --- a/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java +++ b/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_0.java @@ -30,9 +30,9 @@ import org.bukkit.event.world.WorldInitEvent; public abstract class BukkitQueue_0 extends NMSMappedFaweQueue implements Listener { - public Object adapter; - public Method methodToNative; - public Method methodFromNative; + public static Object adapter; + public static Method methodToNative; + public static Method methodFromNative; public BukkitQueue_0(final String world) { super(world); @@ -51,16 +51,6 @@ public abstract class BukkitQueue_0 extends NMSMa return false; } - @Override - public int getEmmittedLight(CHUNKSECTIONS sections, int x, int y, int z) { - return 0; - } - - @Override - public int getSkyLight(CHUNKSECTIONS sections, int x, int y, int z) { - return 15; - } - @Override public void relight(int x, int y, int z) {} diff --git a/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java b/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java index 5c64e8c2..93150d62 100644 --- a/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java +++ b/bukkit0/src/main/java/com/boydti/fawe/bukkit/v0/BukkitQueue_All.java @@ -5,6 +5,7 @@ import com.boydti.fawe.FaweCache; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.RunnableVal; +import com.boydti.fawe.util.TaskManager; import com.sk89q.jnbt.CompoundTag; import org.bukkit.Chunk; import org.bukkit.World; @@ -23,6 +24,16 @@ public class BukkitQueue_All extends BukkitQueue_0 { } } + @Override + public void setSkyLight(int x, int y, int z, int value) { + + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + + } + public int getCombinedId4Data(Chunk section, int x, int y, int z) { Block block = ((Chunk) section).getBlock(x & 15, y, z & 15); int combined = block.getTypeId() << 4; @@ -32,6 +43,45 @@ public class BukkitQueue_All extends BukkitQueue_0 { return combined; } + @Override + public int getEmmittedLight(final Chunk chunk, int x, int y, int z) { + if (!chunk.isLoaded()) { + TaskManager.IMP.sync(new RunnableVal() { + @Override + public void run(Object value) { + chunk.load(true); + } + }); + } + return chunk.getBlock(x, y, z).getLightFromBlocks(); + } + + @Override + public int getSkyLight(final Chunk chunk, int x, int y, int z) { + if (!chunk.isLoaded()) { + TaskManager.IMP.sync(new RunnableVal() { + @Override + public void run(Object value) { + chunk.load(true); + } + }); + } + return chunk.getBlock(x, y, z).getLightFromSky(); + } + + @Override + public int getLight(final Chunk chunk, int x, int y, int z) { + if (!chunk.isLoaded()) { + TaskManager.IMP.sync(new RunnableVal() { + @Override + public void run(Object value) { + chunk.load(true); + } + }); + } + return chunk.getBlock(x, y, z).getLightLevel(); + } + @Override public boolean fixLighting(FaweChunk fc, RelightMode mode) { return false; diff --git a/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java b/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java index 7ed1ba9f..d417f05e 100644 --- a/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java +++ b/bukkit110/src/main/java/com/boydti/fawe/bukkit/v1_10/BukkitQueue_1_10.java @@ -36,6 +36,7 @@ import net.minecraft.server.v1_10_R1.BlockPosition; import net.minecraft.server.v1_10_R1.Blocks; import net.minecraft.server.v1_10_R1.ChunkCoordIntPair; import net.minecraft.server.v1_10_R1.ChunkSection; +import net.minecraft.server.v1_10_R1.DataBits; import net.minecraft.server.v1_10_R1.DataPaletteBlock; import net.minecraft.server.v1_10_R1.Entity; import net.minecraft.server.v1_10_R1.EntityHuman; @@ -77,25 +78,78 @@ import org.bukkit.generator.ChunkGenerator; public class BukkitQueue_1_10 extends BukkitQueue_0 { - private IBlockData air; + private static IBlockData air; + private static Field fieldBits; public BukkitQueue_1_10(final String world) { super(world); checkVersion("v1_10_R1"); - try { - Field fieldAir = DataPaletteBlock.class.getDeclaredField("a"); - fieldAir.setAccessible(true); - air = (IBlockData) fieldAir.get(null); - if (adapter == null) { - setupAdapter(new com.boydti.fawe.bukkit.v1_10.FaweAdapter_1_10()); - Fawe.debug("Using adapter: " + adapter); - Fawe.debug("========================================="); + if (adapter == null) { + try { + Field fieldAir = DataPaletteBlock.class.getDeclaredField("a"); + fieldAir.setAccessible(true); + air = (IBlockData) fieldAir.get(null); + fieldBits = DataPaletteBlock.class.getDeclaredField("b"); + fieldBits.setAccessible(true); + if (adapter == null) { + setupAdapter(new com.boydti.fawe.bukkit.v1_10.FaweAdapter_1_10()); + Fawe.debug("Using adapter: " + adapter); + Fawe.debug("========================================="); + } + } catch (Throwable e) { + throw new RuntimeException(e); } - } catch (Throwable e) { - throw new RuntimeException(e); } } + @Override + public void setSkyLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkyLightArray().a(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value); + } + + private DataBits lastBits; + private DataPaletteBlock lastBlocks; + + @Override + public boolean hasBlock(DataPaletteBlock dataPaletteBlock, int x, int y, int z) { + try { + if (lastBlocks != dataPaletteBlock) { + lastBits = (DataBits) fieldBits.get(dataPaletteBlock); + lastBlocks = dataPaletteBlock; + } + int i = FaweCache.CACHE_J[y][x & 15][z & 15]; + return lastBits.a(i) != 0; + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return false; + } + @Override public World createWorld(final WorldCreator creator) { final String name = creator.name(); diff --git a/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java b/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java index 071c7256..0d1eeb59 100644 --- a/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java +++ b/bukkit1710/src/main/java/com/boydti/fawe/bukkit/v1_7/BukkitQueue17.java @@ -673,4 +673,34 @@ public class BukkitQueue17 extends BukkitQueue_0> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkyLightArray().a(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value); + } } diff --git a/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java b/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java index 05710880..880cb35e 100644 --- a/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java +++ b/bukkit18/src/main/java/com/boydti/fawe/bukkit/v1_8/BukkitQueue18R3.java @@ -659,4 +659,34 @@ public class BukkitQueue18R3 extends BukkitQueue_0> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkyLightArray().a(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value); + } } diff --git a/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java b/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java index 81d4e125..076ec0d4 100644 --- a/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java +++ b/bukkit19/src/main/java/com/boydti/fawe/bukkit/v1_9/BukkitQueue_1_9_R1.java @@ -791,4 +791,34 @@ public class BukkitQueue_1_9_R1 extends BukkitQueue_0> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkyLightArray().a(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ChunkSection[] sections = getCachedSections(getWorld(), cx, cz); + ChunkSection section = sections[y >> 4]; + if (section == null) { + return; + } + section.getEmittedLightArray().a(x & 15, y & 15, z & 15, value); + } } diff --git a/core/src/main/java/com/boydti/fawe/FaweAPI.java b/core/src/main/java/com/boydti/fawe/FaweAPI.java index 8dad9510..c29b2125 100644 --- a/core/src/main/java/com/boydti/fawe/FaweAPI.java +++ b/core/src/main/java/com/boydti/fawe/FaweAPI.java @@ -114,11 +114,17 @@ public class FaweAPI { } public static World getWorld(String worldName) { - for (World current : WorldEdit.getInstance().getServer().getWorlds()) { + List worlds = WorldEdit.getInstance().getServer().getWorlds(); + for (World current : worlds) { if (Fawe.imp().getWorldName(current).equals(worldName)) { return WorldWrapper.wrap((AbstractWorld) current); } } + for (World current : worlds) { + if (current.getName().equals(worldName)) { + return WorldWrapper.wrap((AbstractWorld) current); + } + } return null; } diff --git a/core/src/main/java/com/boydti/fawe/FaweCache.java b/core/src/main/java/com/boydti/fawe/FaweCache.java index 708037bc..bc9b0116 100644 --- a/core/src/main/java/com/boydti/fawe/FaweCache.java +++ b/core/src/main/java/com/boydti/fawe/FaweCache.java @@ -439,7 +439,6 @@ public class FaweCache { case 129: case 133: case 138: - case 137: case 140: case 165: case 166: diff --git a/core/src/main/java/com/boydti/fawe/config/BBC.java b/core/src/main/java/com/boydti/fawe/config/BBC.java index ca4cf99c..a38ff9cf 100644 --- a/core/src/main/java/com/boydti/fawe/config/BBC.java +++ b/core/src/main/java/com/boydti/fawe/config/BBC.java @@ -102,8 +102,8 @@ public enum BBC { VISITOR_ENTITY("%s0 entities affected", "WorldEdit.Visitor"), VISITOR_FLAT("%s0 columns affected", "WorldEdit.Visitor"), - SELECTOR_CUBOID_POS1("First position set to %s0 %s1.", "WorldEdit.Selector"), - SELECTOR_CUBOID_POS2("Second position set to %s0 %s1.", "WorldEdit.Selector"), + SELECTOR_CUBOID_POS1("pos1 set to %s0 %s1.", "WorldEdit.Selector"), + SELECTOR_CUBOID_POS2("pos2 set to %s0 %s1.", "WorldEdit.Selector"), SELECTOR_INVALID_COORDINATES("Invalid coordinates %s0", "WorldEdit.Selector"), SELECTOR_ALREADY_SET("Position already set.", "WorldEdit.Selector"), diff --git a/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java b/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java index db4b5ef5..b43c15cc 100644 --- a/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/example/MappedFaweQueue.java @@ -135,7 +135,7 @@ public abstract class MappedFaweQueue extends FaweQueue { long pair = (long) (cx) << 32 | (cz) & 0xFFFFFFFFL; lastWrappedChunk = this.blocks.get(pair); if (lastWrappedChunk == null) { - lastWrappedChunk = this.getFaweChunk(x >> 4, z >> 4); + lastWrappedChunk = this.getFaweChunk(cx, cz); lastWrappedChunk.setBlock(x & 15, y, z & 15, id, data); FaweChunk previous = this.blocks.put(pair, lastWrappedChunk); if (previous == null) { @@ -386,31 +386,64 @@ public abstract class MappedFaweQueue extends FaweQueue { long average = 0; - @Override - public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException { - if (y < 0 || y > 255) { - return 0; + public boolean ensureChunkLoaded(int cx, int cz) throws FaweException.FaweChunkLoadException { + if (!isChunkLoaded(cx, cz)) { + boolean sync = Thread.currentThread() == Fawe.get().getMainThread(); + if (sync) { + loadChunk(getWorld(), cx, cz, true); + } else if (Settings.HISTORY.CHUNK_WAIT_MS > 0) { + loadChunk.value = new IntegerPair(cx, cz); + TaskManager.IMP.sync(loadChunk, Settings.HISTORY.CHUNK_WAIT_MS); + if (!isChunkLoaded(cx, cz)) { + throw new FaweException.FaweChunkLoadException(); + } + } else { + return false; + } } + return true; + } + + @Override + public boolean hasBlock(int x, int y, int z) throws FaweException.FaweChunkLoadException { int cx = x >> 4; int cz = z >> 4; int cy = y >> 4; if (cx != lastChunkX || cz != lastChunkZ) { lastChunkX = cx; lastChunkZ = cz; - if (!isChunkLoaded(cx, cz)) { - long start = System.currentTimeMillis(); - boolean sync = Thread.currentThread() == Fawe.get().getMainThread(); - if (sync) { - loadChunk(getWorld(), cx, cz, true); - } else if (Settings.HISTORY.CHUNK_WAIT_MS > 0) { - loadChunk.value = new IntegerPair(cx, cz); - TaskManager.IMP.sync(loadChunk, Settings.HISTORY.CHUNK_WAIT_MS); - if (!isChunkLoaded(cx, cz)) { - throw new FaweException.FaweChunkLoadException(); - } - } else { - return 0; - } + if (!ensureChunkLoaded(cx, cz)) { + return false; + } + lastChunkSections = getCachedSections(getWorld(), cx, cz); + lastSection = getCachedSection(lastChunkSections, cy); + } else if (cy != lastChunkY) { + if (lastChunkSections == null) { + return false; + } + lastSection = getCachedSection(lastChunkSections, cy); + } + + if (lastSection == null) { + return false; + } + return hasBlock(lastSection, x, y, z); + } + + public boolean hasBlock(SECTION section, int x, int y, int z) { + return getCombinedId4Data(lastSection, x, y, z) != 0; + } + + @Override + public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException { + int cx = x >> 4; + int cz = z >> 4; + int cy = y >> 4; + if (cx != lastChunkX || cz != lastChunkZ) { + lastChunkX = cx; + lastChunkZ = cz; + if (!ensureChunkLoaded(cx, cz)) { + return 0; } lastChunkSections = getCachedSections(getWorld(), cx, cz); lastSection = getCachedSection(lastChunkSections, cy); diff --git a/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java b/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java index 1df597b7..95a0b5d3 100644 --- a/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/example/NMSMappedFaweQueue.java @@ -97,6 +97,10 @@ public abstract class NMSMappedFaweQueue ex public abstract void relight(int x, int y, int z); + public abstract void setSkyLight(int x, int y, int z, int value); + + public abstract void setBlockLight(int x, int y, int z, int value); + public abstract int getSkyLight(CHUNKSECTION sections, int x, int y, int z); public abstract int getEmmittedLight(CHUNKSECTION sections, int x, int y, int z); diff --git a/core/src/main/java/com/boydti/fawe/object/FaweLocation.java b/core/src/main/java/com/boydti/fawe/object/FaweLocation.java index fb21a170..c9ff23aa 100644 --- a/core/src/main/java/com/boydti/fawe/object/FaweLocation.java +++ b/core/src/main/java/com/boydti/fawe/object/FaweLocation.java @@ -39,6 +39,11 @@ public class FaweLocation { return FaweAPI.getWorld(world); } + @Override + public String toString() { + return world + "," + x + "," + y + "," + z; + } + @Override public int hashCode() { return this.x << (8 + this.z) << (4 + this.y); diff --git a/core/src/main/java/com/boydti/fawe/object/FawePlayer.java b/core/src/main/java/com/boydti/fawe/object/FawePlayer.java index 70450666..aecec376 100644 --- a/core/src/main/java/com/boydti/fawe/object/FawePlayer.java +++ b/core/src/main/java/com/boydti/fawe/object/FawePlayer.java @@ -115,7 +115,7 @@ public abstract class FawePlayer { String currentWorldName = getLocation().world; World world = getWorld(); if (world != null) { - if (world.getName().equals(currentWorldName)) { + if (Fawe.imp().getWorldName(world).equals(currentWorldName)) { getSession().clearHistory(); loadSessionsFromDisk(world); } @@ -176,7 +176,7 @@ public abstract class FawePlayer { final long start = System.currentTimeMillis(); final UUID uuid = getUUID(); final List editIds = new ArrayList<>(); - final File folder = new File(Fawe.imp().getDirectory(), "history" + File.separator + world.getName() + File.separator + uuid); + final File folder = new File(Fawe.imp().getDirectory(), "history" + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid); if (folder.isDirectory()) { for (File file : folder.listFiles()) { if (file.getName().endsWith(".bd")) { diff --git a/core/src/main/java/com/boydti/fawe/object/FaweQueue.java b/core/src/main/java/com/boydti/fawe/object/FaweQueue.java index dd4e6f50..5b7644cc 100644 --- a/core/src/main/java/com/boydti/fawe/object/FaweQueue.java +++ b/core/src/main/java/com/boydti/fawe/object/FaweQueue.java @@ -202,6 +202,10 @@ public abstract class FaweQueue { public abstract void addNotifyTask(Runnable runnable); + public boolean hasBlock(int x, int y, int z) throws FaweException.FaweChunkLoadException { + return getCombinedId4Data(x, y, z) != 0; + } + public abstract int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException; public abstract CompoundTag getTileEntity(int x, int y, int z) throws FaweException.FaweChunkLoadException; diff --git a/core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java b/core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java index 291b4111..f1c73f53 100644 --- a/core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java +++ b/core/src/main/java/com/boydti/fawe/object/brush/CommandBrush.java @@ -1,5 +1,6 @@ package com.boydti.fawe.object.brush; +import com.boydti.fawe.Fawe; import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper; @@ -33,7 +34,7 @@ public class CommandBrush implements Brush { String replaced = command.replace("{x}", position.getBlockX() + "") .replace("{y}", position.getBlockY() + "") .replace("{z}", position.getBlockZ() + "") - .replace("{world}", editSession.getWorld().getName() + "") + .replace("{world}", Fawe.imp().getWorldName(editSession.getWorld()) + "") .replace("{size}", radius + ""); WorldVectorFace face = player.getBlockTraceFace(256, true); diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java b/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java index 67edb0d6..b53cb5fb 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/DiskStorageHistory.java @@ -73,7 +73,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet { public DiskStorageHistory(World world, UUID uuid) { super(world); - String base = "history" + File.separator + world.getName() + File.separator + uuid; + String base = "history" + File.separator + Fawe.imp().getWorldName(world) + File.separator + uuid; File folder = new File(Fawe.imp().getDirectory(), base); int max = 0; if (folder.exists()) { @@ -97,7 +97,7 @@ public class DiskStorageHistory extends FaweStreamChangeSet { private void init(UUID uuid, int i) { this.uuid = uuid; - String base = "history" + File.separator + getWorld().getName() + File.separator + uuid; + String base = "history" + File.separator + Fawe.imp().getWorldName(getWorld()) + File.separator + uuid; base += File.separator + i; nbtfFile = new File(Fawe.imp().getDirectory(), base + ".nbtf"); nbttFile = new File(Fawe.imp().getDirectory(), base + ".nbtt"); diff --git a/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java b/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java index b79a19ae..d93d2214 100644 --- a/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java +++ b/core/src/main/java/com/boydti/fawe/object/changeset/MemoryOptimizedHistory.java @@ -112,7 +112,10 @@ public class MemoryOptimizedHistory extends FaweStreamChangeSet { @Override public InputStream getBlockIS() throws IOException { - FaweInputStream result = ids == null ? null : MainUtil.getCompressedIS(new ByteArrayInputStream(ids)); + if (ids == null) { + return null; + } + FaweInputStream result = MainUtil.getCompressedIS(new ByteArrayInputStream(ids)); result.skip(FaweStreamChangeSet.HEADER_SIZE); return result; } diff --git a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java index 685d1a75..f338fd82 100644 --- a/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java +++ b/core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SchematicWriter.java @@ -54,7 +54,7 @@ public class SchematicWriter implements ClipboardWriter { int x = -1; int y = 0; int z = 0; - int index = 0; + int index = -1; public int[] yarea; public int[] zwidth; diff --git a/forge110/src/main/java/com/boydti/fawe/forge/FaweForge.java b/forge110/src/main/java/com/boydti/fawe/forge/FaweForge.java index 58846960..6c3d79b4 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/FaweForge.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/FaweForge.java @@ -111,7 +111,12 @@ public class FaweForge implements IFawe { if (world instanceof WorldWrapper) { world = ((WorldWrapper) world).getParent(); } - return ((ForgeWorld) world).getWorld().getWorldInfo().getWorldName(); + return getWorldName(((ForgeWorld) world).getWorld()); + + } + + public String getWorldName(net.minecraft.world.World w) { + return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimension(); } @Override diff --git a/forge110/src/main/java/com/boydti/fawe/forge/ForgePlayer.java b/forge110/src/main/java/com/boydti/fawe/forge/ForgePlayer.java index fcde99c3..7d49cfcd 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/ForgePlayer.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/ForgePlayer.java @@ -1,5 +1,6 @@ package com.boydti.fawe.forge; +import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweLocation; @@ -66,7 +67,7 @@ public class ForgePlayer extends FawePlayer { public FaweLocation getLocation() { World world = parent.worldObj; BlockPos pos = parent.getPosition(); - return new FaweLocation(world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ()); + return new FaweLocation(Fawe.imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ()); } @Override diff --git a/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index 42db99c1..0e91c0f3 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -55,7 +55,7 @@ import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.gen.ChunkProviderServer; -import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.common.DimensionManager; public class ForgeQueue_All extends NMSMappedFaweQueue { @@ -687,12 +687,42 @@ public class ForgeQueue_All extends NMSMappedFaweQueue> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkylightArray().set(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getBlocklightArray().set(x & 15, y & 15, z & 15, value); } } diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java b/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java index 8e0199c4..41f185dd 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java @@ -108,7 +108,12 @@ public class FaweForge implements IFawe { if (world instanceof WorldWrapper) { world = ((WorldWrapper) world).getParent(); } - return ((ForgeWorld) world).getWorld().provider.getDimensionName(); + return getWorldName(((ForgeWorld) world).getWorld()); + + } + + public String getWorldName(net.minecraft.world.World w) { + return w.getWorldInfo().getWorldName() + ";" + w.provider.dimensionId; } @Override diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/ForgePlayer.java b/forge1710/src/main/java/com/boydti/fawe/forge/ForgePlayer.java index ee7c5cbb..e5c4e4ad 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/ForgePlayer.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/ForgePlayer.java @@ -1,5 +1,6 @@ package com.boydti.fawe.forge; +import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweLocation; @@ -68,7 +69,7 @@ public class ForgePlayer extends FawePlayer { public FaweLocation getLocation() { World world = parent.worldObj; ChunkCoordinates pos = parent.getPlayerCoordinates(); - return new FaweLocation(world.provider.getDimensionName(), pos.posX, pos.posY, pos.posZ); + return new FaweLocation(Fawe.imp().getWorldName(world), pos.posX, pos.posY, pos.posZ); } @Override diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index 937263e2..006fcd42 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -37,7 +37,6 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S13PacketDestroyEntities; import net.minecraft.network.play.server.S21PacketChunkData; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.management.PlayerManager; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IntHashMap; @@ -51,6 +50,7 @@ import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraftforge.common.DimensionManager; public class ForgeQueue_All extends NMSMappedFaweQueue { @@ -680,12 +680,41 @@ public class ForgeQueue_All extends NMSMappedFaweQueue> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkylightArray().set(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getBlocklightArray().set(x & 15, y & 15, z & 15, value); } } diff --git a/forge189/src/main/java/com/boydti/fawe/forge/FaweForge.java b/forge189/src/main/java/com/boydti/fawe/forge/FaweForge.java index 8c0d5743..73b94627 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/FaweForge.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/FaweForge.java @@ -111,7 +111,12 @@ public class FaweForge implements IFawe { if (world instanceof WorldWrapper) { world = ((WorldWrapper) world).getParent(); } - return ((ForgeWorld) world).getWorld().provider.getDimensionName(); + return getWorldName(((ForgeWorld) world).getWorld()); + + } + + public String getWorldName(net.minecraft.world.World w) { + return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimensionId(); } @Override diff --git a/forge189/src/main/java/com/boydti/fawe/forge/ForgePlayer.java b/forge189/src/main/java/com/boydti/fawe/forge/ForgePlayer.java index 2ed95a79..56af1a9e 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/ForgePlayer.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/ForgePlayer.java @@ -1,5 +1,6 @@ package com.boydti.fawe.forge; +import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweLocation; @@ -69,7 +70,7 @@ public class ForgePlayer extends FawePlayer { public FaweLocation getLocation() { World world = parent.worldObj; BlockPos pos = parent.getPosition(); - return new FaweLocation(world.provider.getDimensionName(), pos.getX(), pos.getY(), pos.getZ()); + return new FaweLocation(Fawe.imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ()); } @Override diff --git a/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index ea755950..422e8513 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -35,7 +35,6 @@ import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S13PacketDestroyEntities; import net.minecraft.network.play.server.S21PacketChunkData; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.management.PlayerManager; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; @@ -49,6 +48,7 @@ import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraftforge.common.DimensionManager; public class ForgeQueue_All extends NMSMappedFaweQueue { @@ -643,12 +643,41 @@ public class ForgeQueue_All extends NMSMappedFaweQueue> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkylightArray().set(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getBlocklightArray().set(x & 15, y & 15, z & 15, value); } } diff --git a/forge194/src/main/java/com/boydti/fawe/forge/FaweForge.java b/forge194/src/main/java/com/boydti/fawe/forge/FaweForge.java index 58846960..6c3d79b4 100644 --- a/forge194/src/main/java/com/boydti/fawe/forge/FaweForge.java +++ b/forge194/src/main/java/com/boydti/fawe/forge/FaweForge.java @@ -111,7 +111,12 @@ public class FaweForge implements IFawe { if (world instanceof WorldWrapper) { world = ((WorldWrapper) world).getParent(); } - return ((ForgeWorld) world).getWorld().getWorldInfo().getWorldName(); + return getWorldName(((ForgeWorld) world).getWorld()); + + } + + public String getWorldName(net.minecraft.world.World w) { + return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimension(); } @Override diff --git a/forge194/src/main/java/com/boydti/fawe/forge/ForgePlayer.java b/forge194/src/main/java/com/boydti/fawe/forge/ForgePlayer.java index dab16474..4c6ee94f 100644 --- a/forge194/src/main/java/com/boydti/fawe/forge/ForgePlayer.java +++ b/forge194/src/main/java/com/boydti/fawe/forge/ForgePlayer.java @@ -1,5 +1,6 @@ package com.boydti.fawe.forge; +import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.FaweLocation; @@ -68,7 +69,7 @@ public class ForgePlayer extends FawePlayer { public FaweLocation getLocation() { World world = parent.worldObj; BlockPos pos = parent.getPosition(); - return new FaweLocation(world.getWorldInfo().getWorldName(), pos.getX(), pos.getY(), pos.getZ()); + return new FaweLocation(Fawe.imp().getWorldName(world), pos.getX(), pos.getY(), pos.getZ()); } @Override diff --git a/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java b/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java index a89bbb07..bb628d19 100644 --- a/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java +++ b/forge194/src/main/java/com/boydti/fawe/forge/v0/ForgeQueue_All.java @@ -55,7 +55,7 @@ import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.chunk.NibbleArray; import net.minecraft.world.chunk.storage.ExtendedBlockStorage; import net.minecraft.world.gen.ChunkProviderServer; -import net.minecraftforge.fml.common.FMLCommonHandler; +import net.minecraftforge.common.DimensionManager; public class ForgeQueue_All extends NMSMappedFaweQueue { @@ -687,12 +687,41 @@ public class ForgeQueue_All extends NMSMappedFaweQueue> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getSkylightArray().set(x & 15, y & 15, z & 15, value); + } + + @Override + public void setBlockLight(int x, int y, int z, int value) { + int cx = x >> 4; + int cz = z >> 4; + if (!ensureChunkLoaded(cx, cz)) { + return; + } + ExtendedBlockStorage[] sections = getCachedSections(getWorld(), cx, cz); + ExtendedBlockStorage section = sections[y >> 4]; + if (section == null) { + return; + } + section.getBlocklightArray().set(x & 15, y & 15, z & 15, value); } }