Fix __reserved__ being solid

This commit is contained in:
Jesse Boyd 2018-08-17 19:21:45 +10:00
parent 177bfaa930
commit 43d5459595
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
4 changed files with 24 additions and 3 deletions

View File

@ -1,5 +1,6 @@
package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.bukkit.util.BukkitReflectionUtils;
import com.boydti.fawe.config.Settings;
@ -21,6 +22,7 @@ import java.lang.reflect.Method;
import java.util.ArrayDeque;
import java.util.Map;
import java.util.concurrent.ConcurrentMap;
import java.util.function.Supplier;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -65,7 +67,7 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
@Override
public void onLoad(Chunk chunk) {
try {
ChunkSnapshot snapshot = chunk.getChunkSnapshot();
ChunkSnapshot snapshot = tryGetSnasphot(chunk);
operation.run(snapshot);
} catch (Throwable e) {
PAPER = false;
@ -302,8 +304,25 @@ public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot,
return chunk.isLoaded() ? getAndCacheChunk(chunk) : null;
}
private ChunkSnapshot tryGetSnasphot(Chunk chunk) {
try {
return chunk.getChunkSnapshot(false, true, false);
} catch (IllegalStateException ignore) {
return null;
}
}
private ChunkSnapshot getAndCacheChunk(Chunk chunk) {
ChunkSnapshot snapshot = chunk.getChunkSnapshot(false, true, false);
ChunkSnapshot snapshot = tryGetSnasphot(chunk);
if (snapshot == null) {
snapshot = tryGetSnasphot(chunk);
if (snapshot == null) {
snapshot = TaskManager.IMP.sync(() -> tryGetSnasphot(chunk));
if (snapshot == null) {
snapshot = chunk.getChunkSnapshot(false, true, false);
}
}
}
chunkCache.put(MathMan.pairInt(chunk.getX(), chunk.getZ()), snapshot);
return snapshot;
}

View File

@ -49,6 +49,7 @@ public class BukkitBlockRegistry extends BundledBlockRegistry {
public BlockMaterial getMaterial(BlockType blockType) {
Material type = BukkitAdapter.adapt(blockType);
if (type == null) {
if (blockType == BlockTypes.__RESERVED__) return new PassthroughBlockMaterial(super.getMaterial(BlockTypes.AIR));
return new PassthroughBlockMaterial(null);
}
return materialMap.computeIfAbsent(type, m -> new BukkitBlockMaterial(BukkitBlockRegistry.super.getMaterial(blockType), m));

View File

@ -121,7 +121,7 @@ public class ImageBrush implements Brush {
if (color != 0) {
BlockType block = texture.getNearestBlock(color);
if (block != null) {
editSession.setBlock(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), block.getDefaultState());
editSession.setBlock(vector, block.getDefaultState());
}
}
return true;

View File

@ -1012,6 +1012,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
@Override
public boolean setBlock(Vector position, BlockStateHolder block) throws MaxChangedBlocksException {
this.changes++;
try {
return this.extent.setBlock(position, block);
} catch (MaxChangedBlocksException e) {