From 30d544b57d15e07585d9bc5870c38df54513f361 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 12 Jul 2017 13:51:28 +1000 Subject: [PATCH] Some fixes for 1.7.10 --- build.gradle | 2 +- .../com/boydti/fawe/example/NMSRelighter.java | 1 + .../java/com/boydti/fawe/util/SetQueue.java | 4 +- .../boydti/fawe/wrappers/PlayerWrapper.java | 3 +- .../boydti/fawe/wrappers/WorldWrapper.java | 3 ++ .../java/com/sk89q/worldedit/EditSession.java | 2 +- .../extension/platform/CommandManager.java | 1 - .../extension/platform/PlatformManager.java | 2 + .../fawe/forge/v110/ForgeChunk_All.java | 3 +- .../java/com/boydti/fawe/forge/FaweForge.java | 9 ++++ .../fawe/forge/v1710/ForgeChunk_All.java | 49 +++++++++++-------- .../fawe/forge/v1710/ForgeQueue_All.java | 2 +- .../java/com/boydti/fawe/forge/FaweForge.java | 9 ++++ 13 files changed, 61 insertions(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index c5b6d636..3aef1232 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,7 @@ ext { date = git.head().date.format("yy.MM.dd") revision = "-${git.head().abbreviatedId}" parents = git.head().parentIds; - index = -95; // Offset to match CI + index = -96; // Offset to match CI int major, minor, patch; major = minor = patch = 0; for (;parents != null && !parents.isEmpty();index++) { diff --git a/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java b/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java index ef82a24f..db595313 100644 --- a/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java +++ b/core/src/main/java/com/boydti/fawe/example/NMSRelighter.java @@ -261,6 +261,7 @@ public class NMSRelighter implements Relighter { } public void fixLightingSafe(boolean sky) { + if (isEmpty()) return; try { if (sky) { fixSkyLighting(); diff --git a/core/src/main/java/com/boydti/fawe/util/SetQueue.java b/core/src/main/java/com/boydti/fawe/util/SetQueue.java index cd1eeca6..8bddd1c0 100644 --- a/core/src/main/java/com/boydti/fawe/util/SetQueue.java +++ b/core/src/main/java/com/boydti/fawe/util/SetQueue.java @@ -236,18 +236,18 @@ public class SetQueue { } public void flush(FaweQueue queue) { - queue.startSet(Settings.IMP.QUEUE.PARALLEL_THREADS > 1); try { + queue.startSet(Settings.IMP.QUEUE.PARALLEL_THREADS > 1); queue.next(Settings.IMP.QUEUE.PARALLEL_THREADS, Long.MAX_VALUE); } catch (Throwable e) { pool.awaitQuiescence(Settings.IMP.QUEUE.DISCARD_AFTER_MS, TimeUnit.MILLISECONDS); completer = new ExecutorCompletionService(pool); MainUtil.handleError(e); } finally { + queue.endSet(Settings.IMP.QUEUE.PARALLEL_THREADS > 1); queue.setStage(QueueStage.NONE); queue.runTasks(); } - queue.endSet(Settings.IMP.QUEUE.PARALLEL_THREADS > 1); } public FaweQueue getNextQueue() { diff --git a/core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java b/core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java index 747e3c70..5622e4aa 100644 --- a/core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java +++ b/core/src/main/java/com/boydti/fawe/wrappers/PlayerWrapper.java @@ -26,7 +26,6 @@ import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.TargetBlock; import com.sk89q.worldedit.util.auth.AuthorizationException; -import com.sk89q.worldedit.world.AbstractWorld; import com.sk89q.worldedit.world.World; import java.io.File; import java.util.UUID; @@ -52,7 +51,7 @@ public class PlayerWrapper extends AbstractPlayerActor { @Override public World getWorld() { - return WorldWrapper.wrap((AbstractWorld) parent.getWorld()); + return WorldWrapper.wrap(parent.getWorld()); } @Override diff --git a/core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java b/core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java index 7b3ca39e..b32d657a 100644 --- a/core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java +++ b/core/src/main/java/com/boydti/fawe/wrappers/WorldWrapper.java @@ -50,6 +50,9 @@ public class WorldWrapper extends LocalWorld { if (world instanceof LocalWorldAdapter) { return unwrap(LocalWorldAdapter.unwrap(world)); } + else if (world instanceof EditSession) { + return unwrap(((EditSession) world).getWorld()); + } return world; } diff --git a/core/src/main/java/com/sk89q/worldedit/EditSession.java b/core/src/main/java/com/sk89q/worldedit/EditSession.java index 75e70009..98820bfd 100644 --- a/core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -905,7 +905,7 @@ public class EditSession extends AbstractWorld implements HasFaweQueue, Lighting @Override public String toString() { - return super.toString() + ":" + extent.toString(); + return super.toString() + ":" + extent; } /** diff --git a/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index f10b29d6..70bee291 100644 --- a/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/core/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -370,7 +370,6 @@ public final class CommandManager { Request.reset(); locals.put(Actor.class, actor); final Actor finalActor = actor; - locals.put("arguments", args); long start = System.currentTimeMillis(); try { diff --git a/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 6e531339..4a587b5c 100644 --- a/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -26,6 +26,7 @@ import com.boydti.fawe.object.pattern.PatternTraverser; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper; import com.boydti.fawe.wrappers.PlayerWrapper; +import com.boydti.fawe.wrappers.WorldWrapper; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; import com.sk89q.worldedit.ServerInterface; @@ -258,6 +259,7 @@ public class PlatformManager { */ public World getWorldForEditing(World base) { checkNotNull(base); + base = WorldWrapper.unwrap(base); World match = queryCapability(Capability.WORLD_EDITING).matchWorld(base); return match != null ? match : base; } diff --git a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java index fef8712e..e824588b 100644 --- a/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java +++ b/forge110/src/main/java/com/boydti/fawe/forge/v110/ForgeChunk_All.java @@ -134,10 +134,11 @@ public class ForgeChunk_All extends CharFaweChunk { } BlockStateContainer palette = new BlockStateContainer(); char[] blocks = getIdArray(layer); + int index = 0; for (int y = 0; y < 16; y++) { for (int z = 0; z < 16; z++) { for (int x = 0; x < 16; x++) { - char combinedId = blocks[FaweCache.CACHE_J[y][z][x]]; + char combinedId = blocks[index++]; if (combinedId > 1) { palette.set(x, y, z, Block.getBlockById(combinedId >> 4).getStateFromMeta(combinedId & 0xF)); } 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 07a8e7b2..f6919768 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/FaweForge.java @@ -27,6 +27,8 @@ import javax.management.InstanceAlreadyExistsException; import net.minecraft.command.ServerCommandManager; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.DimensionManager; import org.apache.logging.log4j.Logger; public class FaweForge implements IFawe { @@ -120,6 +122,13 @@ public class FaweForge implements IFawe { } public String getWorldName(net.minecraft.world.World w) { + Integer[] ids = DimensionManager.getIDs(); + WorldServer[] worlds = DimensionManager.getWorlds(); + for (int i = 0; i < ids.length; i++) { + if (worlds[i] == w) { + return w.getWorldInfo().getWorldName() + ";" + ids[i]; + } + } return w.getWorldInfo().getWorldName() + ";" + w.provider.dimensionId; } diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java index 487e4521..0c5f6132 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeChunk_All.java @@ -99,6 +99,7 @@ public class ForgeChunk_All extends CharFaweChunk { this.count[i]++; switch (id) { case 0: + this.air[i]++; vs[j] = 0; vs2[j] = (char) 1; return; @@ -280,15 +281,13 @@ public class ForgeChunk_All extends CharFaweChunk { section.setBlockLSBArray(newIdArray); if (newDataArray != null) { section.setBlockMetadataArray(newDataArray); - } else { - NibbleArray nibble = section.getMetadataArray(); - Arrays.fill(nibble.data, (byte) 0); + } else if (section.getMetadataArray() != null) { + Arrays.fill(section.getMetadataArray().data, (byte) 0); } if (extendedArray != null) { section.setBlockMSBArray(extendedArray); - } else { - NibbleArray nibble = section.getBlockMSBArray(); - Arrays.fill(nibble.data, (byte) 0); + } else if (section.getBlockMSBArray() != null) { + Arrays.fill(section.getBlockMSBArray().data, (byte) 0); } continue; } @@ -326,22 +325,32 @@ public class ForgeChunk_All extends CharFaweChunk { solid++; currentIdArray[k] = newIdArray[k]; if (data) { - int dataByte = FaweCache.getData(combined); - int x = FaweCache.CACHE_X[0][k]; - int y = FaweCache.CACHE_Y[0][k]; - int z = FaweCache.CACHE_Z[0][k]; - int newData = newDataArray.get(x, y, z); - currentDataArray.set(x, y, z, newData); - } - if (extra) { - int extraId = FaweCache.getId(combined) >> 8; - if (extraId != 0) { + if (FaweCache.hasData(combined >> 4)) { + int dataByte = FaweCache.getData(combined); int x = FaweCache.CACHE_X[0][k]; int y = FaweCache.CACHE_Y[0][k]; int z = FaweCache.CACHE_Z[0][k]; - int newExtra = extendedArray.get(x, y, z); - currentExtraArray.set(x, y, z, newExtra); + int newData = newDataArray.get(x, y, z); + currentDataArray.set(x, y, z, newData); } + } else if (currentDataArray != null) { + int x = FaweCache.CACHE_X[0][k]; + int y = FaweCache.CACHE_Y[0][k]; + int z = FaweCache.CACHE_Z[0][k]; + currentDataArray.set(x, y, z, 0); + } + int extraId = FaweCache.getId(combined) >> 8; + if (extra && extraId != 0) { + int x = FaweCache.CACHE_X[0][k]; + int y = FaweCache.CACHE_Y[0][k]; + int z = FaweCache.CACHE_Z[0][k]; + int newExtra = extendedArray.get(x, y, z); + currentExtraArray.set(x, y, z, newExtra); + } else if (currentExtraArray != null) { + int x = FaweCache.CACHE_X[0][k]; + int y = FaweCache.CACHE_Y[0][k]; + int z = FaweCache.CACHE_Z[0][k]; + currentExtraArray.set(x, y, z, 0); } continue; } @@ -373,8 +382,8 @@ public class ForgeChunk_All extends CharFaweChunk { if (tileEntity != null) { NBTTagCompound tag = (NBTTagCompound) ForgeQueue_All.methodFromNative.invoke(null, nativeTag); tag.setInteger("x", x); - tag.setInteger("y", x); - tag.setInteger("z", x); + tag.setInteger("y", y); + tag.setInteger("z", z); tileEntity.readFromNBT(tag); // ReadTagIntoTile } } diff --git a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java index 3084d5db..84a38f9b 100644 --- a/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java +++ b/forge1710/src/main/java/com/boydti/fawe/forge/v1710/ForgeQueue_All.java @@ -108,7 +108,7 @@ public class ForgeQueue_All extends NMSMappedFaweQueue tiles = chunk.chunkTileEntityMap; - ChunkPosition pos = new ChunkPosition(x, y, z); + ChunkPosition pos = new ChunkPosition(x & 15, y, z & 15); TileEntity tile = tiles.get(pos); return tile != null ? getTag(tile) : null; } 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 12753881..1e8911f8 100644 --- a/forge189/src/main/java/com/boydti/fawe/forge/FaweForge.java +++ b/forge189/src/main/java/com/boydti/fawe/forge/FaweForge.java @@ -25,6 +25,8 @@ import javax.management.InstanceAlreadyExistsException; import net.minecraft.command.ServerCommandManager; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.server.MinecraftServer; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.DimensionManager; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.ModMetadata; import org.apache.logging.log4j.Logger; @@ -123,6 +125,13 @@ public class FaweForge implements IFawe { } public String getWorldName(net.minecraft.world.World w) { + Integer[] ids = DimensionManager.getIDs(); + WorldServer[] worlds = DimensionManager.getWorlds(); + for (int i = 0; i < ids.length; i++) { + if (worlds[i] == w) { + return w.getWorldInfo().getWorldName() + ";" + ids[i]; + } + } return w.getWorldInfo().getWorldName() + ";" + w.provider.getDimensionId(); }