Put the synchronisation higher up the food chain

Dieser Commit ist enthalten in:
dordsor21 2020-05-14 22:32:32 +01:00
Ursprung 3a7c23be45
Commit 5be11c541b
3 geänderte Dateien mit 8 neuen und 21 gelöschten Zeilen

Datei anzeigen

@ -75,8 +75,6 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
public Chunk nmsChunk; public Chunk nmsChunk;
public WorldServer world; public WorldServer world;
public int X, Z; 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) { public BukkitGetBlocks_1_15(World world, int X, int Z) {
this(((CraftWorld) world).getHandle(), X, Z); this(((CraftWorld) world).getHandle(), X, Z);
@ -108,10 +106,8 @@ public class BukkitGetBlocks_1_15 extends CharGetBlocks {
} else { } else {
base = index.getBiome(x >> 2, y >> 2, z >> 2); 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 @Override
public CompoundTag getTile(int x, int y, int z) { public CompoundTag getTile(int x, int y, int z) {

Datei anzeigen

@ -80,8 +80,6 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
public Chunk nmsChunk; public Chunk nmsChunk;
public WorldServer world; public WorldServer world;
public int X, Z; 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) { public BukkitGetBlocks_1_15_2(World world, int X, int Z) {
this(((CraftWorld) world).getHandle(), X, Z); this(((CraftWorld) world).getHandle(), X, Z);
@ -113,10 +111,8 @@ public class BukkitGetBlocks_1_15_2 extends CharGetBlocks {
} else { } else {
base = index.getBiome(x >> 2, y >> 2, z >> 2); 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 @Override
public CompoundTag getTile(int x, int y, int z) { public CompoundTag getTile(int x, int y, int z) {

Datei anzeigen

@ -19,8 +19,6 @@
package com.sk89q.worldedit.extent; package com.sk89q.worldedit.extent;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.beta.Filter; import com.boydti.fawe.beta.Filter;
import com.boydti.fawe.beta.IBatchProcessor; 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.CharFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock; import com.boydti.fawe.beta.implementation.filter.block.ChunkFilterBlock;
import com.boydti.fawe.beta.implementation.filter.block.FilterBlock; 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.google.common.cache.LoadingCache;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.function.mask.Mask; 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.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull;
import java.util.concurrent.ConcurrentHashMap;
/** /**
* Requires that all mutating methods pass a given {@link Mask}. * Requires that all mutating methods pass a given {@link Mask}.
@ -107,11 +100,13 @@ public class MaskingExtent extends AbstractDelegateExtent implements IBatchProce
@Override @Override
public void applyBlock(FilterBlock block) { public void applyBlock(FilterBlock block) {
int ordinal = block.getOrdinal(); //TODO: Find a way to make masking thread safe without having to synchonise the whole extent
synchronized (this) {
if (!mask.test(getExtent(), block)) { if (!mask.test(getExtent(), block)) {
block.setOrdinal(0); block.setOrdinal(0);
} }
} }
}
@Override @Override
public Extent construct(Extent child) { public Extent construct(Extent child) {