From 5be11c541bff9a065e181a71c33ff09c483e25cd Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Thu, 14 May 2020 22:32:32 +0100 Subject: [PATCH] Put the synchronisation higher up the food chain --- .../adapter/mc1_15/BukkitGetBlocks_1_15.java | 6 +----- .../mc1_15_2/BukkitGetBlocks_1_15_2.java | 6 +----- .../sk89q/worldedit/extent/MaskingExtent.java | 17 ++++++----------- 3 files changed, 8 insertions(+), 21 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java index c82e41521..21c5f48f7 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15/BukkitGetBlocks_1_15.java @@ -75,8 +75,6 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { public Chunk nmsChunk; public WorldServer world; public int X, Z; - //This is (hopefully) a temp fix for random blocks returning the wrong biome. Static because it was seemingly using the wrong chunk to return the biome value. - private static final Object biomeLock = new Object(); public BukkitGetBlocks_1_15(World world, int X, int Z) { this(((CraftWorld) world).getHandle(), X, Z); @@ -108,9 +106,7 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks { } else { base = index.getBiome(x >> 2, y >> 2, z >> 2); } - synchronized (biomeLock) { - return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null; - } + return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null; } @Override diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java index 92cedc21d..efe33059b 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/adapter/mc1_15_2/BukkitGetBlocks_1_15_2.java @@ -80,8 +80,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { public Chunk nmsChunk; public WorldServer world; public int X, Z; - //This is (hopefully) a temp fix for random blocks returning the wrong biome. Static because it was seemingly using the wrong chunk to return the biome value. - private static final Object biomeLock = new Object(); public BukkitGetBlocks_1_15_2(World world, int X, int Z) { this(((CraftWorld) world).getHandle(), X, Z); @@ -113,9 +111,7 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks { } else { base = index.getBiome(x >> 2, y >> 2, z >> 2); } - synchronized (biomeLock) { - return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null; - } + return base != null ? BukkitAdapter.adapt(CraftBlock.biomeBaseToBiome(base)) : null; } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java index 7cb88c422..5efc02859 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java @@ -19,8 +19,6 @@ package com.sk89q.worldedit.extent; -import static com.google.common.base.Preconditions.checkNotNull; - import com.boydti.fawe.FaweCache; import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.IBatchProcessor; @@ -30,10 +28,6 @@ import com.boydti.fawe.beta.IChunkSet; import com.boydti.fawe.beta.implementation.filter.block.CharFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; -import com.boydti.fawe.util.ExtentTraverser; -import com.google.common.cache.Cache; -import com.google.common.cache.CacheBuilder; -import com.google.common.cache.CacheLoader; import com.google.common.cache.LoadingCache; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.function.mask.Mask; @@ -42,8 +36,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; +import static com.google.common.base.Preconditions.checkNotNull; /** * Requires that all mutating methods pass a given {@link Mask}. @@ -107,9 +100,11 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce @Override public void applyBlock(FilterBlock block) { - int ordinal = block.getOrdinal(); - if (!mask.test(getExtent(), block)) { - block.setOrdinal(0); + //TODO: Find a way to make masking thread safe without having to synchonise the whole extent + synchronized (this) { + if (!mask.test(getExtent(), block)) { + block.setOrdinal(0); + } } }