3
0
Mirror von https://github.com/IntellectualSites/FastAsyncWorldEdit.git synchronisiert 2024-11-17 00:20:09 +01:00

Better chest handling

Dieser Commit ist enthalten in:
dordsor21 2024-06-01 12:10:11 +01:00
Ursprung b069e07c25
Commit 64da82c985
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 1E53E88969FFCF0B
12 geänderte Dateien mit 127 neuen und 65 gelöschten Zeilen

Datei anzeigen

@ -14,20 +14,21 @@ import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext { public class PaperweightFaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3( private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(
Integer.MAX_VALUE, new Vec3(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
Integer.MAX_VALUE, Direction.NORTH,
Integer.MAX_VALUE new BlockPos(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
), Direction.NORTH, BlockPos.ZERO, false); false
);
private final ServerLevel level; private final ServerLevel level;
private BlockHitResult hitResult = null; private BlockHitResult hitResult = null;
private Direction direction = null; private Direction direction = null;
private BlockPos relativePos; private BlockPos relativePos;
@SuppressWarnings("DataFlowIssue") @SuppressWarnings("DataFlowIssue")
public FaweMutableBlockPlaceContext(ServerLevel level) { public PaperweightFaweMutableBlockPlaceContext(ServerLevel level) {
super( super(
level, level,
null, null,
@ -40,7 +41,7 @@ public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
this.replaceClicked = false; this.replaceClicked = false;
} }
public FaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) { public PaperweightFaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) {
this.hitResult = hitResult; this.hitResult = hitResult;
this.direction = direction; this.direction = direction;
this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection()); this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection());

Datei anzeigen

@ -24,13 +24,13 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin
.getInstance() .getInstance()
.getBukkitImplAdapter()); .getBukkitImplAdapter());
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext; private final PaperweightFaweMutableBlockPlaceContext mutableBlockPlaceContext;
private final PaperweightLevelProxy proxyLevel; private final PaperweightLevelProxy proxyLevel;
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) { public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region); super(extent, mask, region);
this.proxyLevel = PaperweightLevelProxy.getInstance(this); this.proxyLevel = PaperweightLevelProxy.getInstance(this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
private PaperweightPlacementStateProcessor( private PaperweightPlacementStateProcessor(
@ -43,7 +43,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
) { ) {
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished); super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
this.proxyLevel = PaperweightLevelProxy.getInstance(this); this.proxyLevel = PaperweightLevelProxy.getInstance(this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
@Override @Override

Datei anzeigen

@ -14,33 +14,29 @@ import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext { public class PaperweightFaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3( private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(
Integer.MAX_VALUE, new Vec3(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
Integer.MAX_VALUE, Direction.NORTH,
Integer.MAX_VALUE new BlockPos(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
), Direction.NORTH, BlockPos.ZERO, false); false
);
private final ServerLevel level; private final ServerLevel level;
private BlockHitResult hitResult = null; private BlockHitResult hitResult = null;
private Direction direction = null; private Direction direction = null;
private BlockPos relativePos; private BlockPos relativePos;
@SuppressWarnings("DataFlowIssue") @SuppressWarnings("DataFlowIssue")
public FaweMutableBlockPlaceContext(ServerLevel level) { public PaperweightFaweMutableBlockPlaceContext(ServerLevel level) {
super( super(level, null, null, null, DEFAULT_BLOCK_HIT
level,
null,
null,
null,
DEFAULT_BLOCK_HIT
); );
this.level = level; this.level = level;
this.replaceClicked = false; this.replaceClicked = false;
} }
public FaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) { public PaperweightFaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) {
this.hitResult = hitResult; this.hitResult = hitResult;
this.direction = direction; this.direction = direction;
this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection()); this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection());

Datei anzeigen

@ -24,13 +24,13 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin
.getInstance() .getInstance()
.getBukkitImplAdapter()); .getBukkitImplAdapter());
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext; private final PaperweightFaweMutableBlockPlaceContext mutableBlockPlaceContext;
private final PaperweightLevelProxy proxyLevel; private final PaperweightLevelProxy proxyLevel;
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) { public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region); super(extent, mask, region);
this.proxyLevel = PaperweightLevelProxy.getInstance(this); this.proxyLevel = PaperweightLevelProxy.getInstance(this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
private PaperweightPlacementStateProcessor( private PaperweightPlacementStateProcessor(
@ -43,12 +43,18 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
) { ) {
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished); super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
this.proxyLevel = PaperweightLevelProxy.getInstance(this); this.proxyLevel = PaperweightLevelProxy.getInstance(this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
@Override @Override
protected char getStateAtFor( protected char getStateAtFor(
int x, int y, int z, BlockState state, Vector3 clickPos, Direction clickedFaceDirection, BlockVector3 clickedBlock int x,
int y,
int z,
BlockState state,
Vector3 clickPos,
Direction clickedFaceDirection,
BlockVector3 clickedBlock
) { ) {
Block block = ((PaperweightBlockMaterial) state.getMaterial()).getBlock(); Block block = ((PaperweightBlockMaterial) state.getMaterial()).getBlock();
Vec3 pos = new Vec3(clickPos.x(), clickPos.y(), clickPos.z()); Vec3 pos = new Vec3(clickPos.x(), clickPos.y(), clickPos.z());

Datei anzeigen

@ -14,20 +14,21 @@ import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext { public class PaperweightFaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3( private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(
Integer.MAX_VALUE, new Vec3(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
Integer.MAX_VALUE, Direction.NORTH,
Integer.MAX_VALUE new BlockPos(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
), Direction.NORTH, BlockPos.ZERO, false); false
);
private final ServerLevel level; private final ServerLevel level;
private BlockHitResult hitResult = null; private BlockHitResult hitResult = null;
private Direction direction = null; private Direction direction = null;
private BlockPos relativePos; private BlockPos relativePos;
@SuppressWarnings("DataFlowIssue") @SuppressWarnings("DataFlowIssue")
public FaweMutableBlockPlaceContext(ServerLevel level) { public PaperweightFaweMutableBlockPlaceContext(ServerLevel level) {
super( super(
level, level,
null, null,
@ -40,7 +41,7 @@ public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
this.replaceClicked = false; this.replaceClicked = false;
} }
public FaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) { public PaperweightFaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) {
this.hitResult = hitResult; this.hitResult = hitResult;
this.direction = direction; this.direction = direction;
this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection()); this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection());

Datei anzeigen

@ -31,7 +31,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
.getInstance() .getInstance()
.getBukkitImplAdapter()); .getBukkitImplAdapter());
private final PaperweightLevelProxy proxyLevel; private final PaperweightLevelProxy proxyLevel;
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext; private final PaperweightFaweMutableBlockPlaceContext mutableBlockPlaceContext;
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) { public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
super(extent, mask, region); super(extent, mask, region);
@ -47,7 +47,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
bukkitWorld = (BukkitWorld) world; bukkitWorld = (BukkitWorld) world;
} }
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this); this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
private PaperweightPlacementStateProcessor( private PaperweightPlacementStateProcessor(
@ -61,7 +61,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
) { ) {
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished); super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
this.proxyLevel = PaperweightLevelProxy.getInstance(serverLevel, this); this.proxyLevel = PaperweightLevelProxy.getInstance(serverLevel, this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
@Override @Override

Datei anzeigen

@ -14,20 +14,21 @@ import net.minecraft.world.phys.Vec3;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class FaweMutableBlockPlaceContext extends BlockPlaceContext { public class PaperweightFaweMutableBlockPlaceContext extends BlockPlaceContext {
private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(new Vec3( private static final BlockHitResult DEFAULT_BLOCK_HIT = new BlockHitResult(
Integer.MAX_VALUE, new Vec3(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
Integer.MAX_VALUE, Direction.NORTH,
Integer.MAX_VALUE new BlockPos(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE),
), Direction.NORTH, BlockPos.ZERO, false); false
);
private final ServerLevel level; private final ServerLevel level;
private BlockHitResult hitResult = null; private BlockHitResult hitResult = null;
private Direction direction = null; private Direction direction = null;
private BlockPos relativePos; private BlockPos relativePos;
@SuppressWarnings("DataFlowIssue") @SuppressWarnings("DataFlowIssue")
public FaweMutableBlockPlaceContext(ServerLevel level) { public PaperweightFaweMutableBlockPlaceContext(ServerLevel level) {
super( super(
level, level,
null, null,
@ -40,7 +41,7 @@ public class FaweMutableBlockPlaceContext extends BlockPlaceContext {
this.replaceClicked = false; this.replaceClicked = false;
} }
public FaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) { public PaperweightFaweMutableBlockPlaceContext withSetting(BlockHitResult hitResult, Direction direction) {
this.hitResult = hitResult; this.hitResult = hitResult;
this.direction = direction; this.direction = direction;
this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection()); this.relativePos = hitResult.getBlockPos().relative(hitResult.getDirection());

Datei anzeigen

@ -30,7 +30,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin private final PaperweightFaweAdapter adapter = ((PaperweightFaweAdapter) WorldEditPlugin
.getInstance() .getInstance()
.getBukkitImplAdapter()); .getBukkitImplAdapter());
private final FaweMutableBlockPlaceContext mutableBlockPlaceContext; private final PaperweightFaweMutableBlockPlaceContext mutableBlockPlaceContext;
private final PaperweightLevelProxy proxyLevel; private final PaperweightLevelProxy proxyLevel;
public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) { public PaperweightPlacementStateProcessor(Extent extent, BlockTypeMask mask, Region region) {
@ -47,7 +47,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
bukkitWorld = (BukkitWorld) world; bukkitWorld = (BukkitWorld) world;
} }
this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this); this.proxyLevel = PaperweightLevelProxy.getInstance(((CraftWorld) bukkitWorld.getWorld()).getHandle(), this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
private PaperweightPlacementStateProcessor( private PaperweightPlacementStateProcessor(
@ -61,7 +61,7 @@ public class PaperweightPlacementStateProcessor extends PlacementStateProcessor
) { ) {
super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished); super(extent, mask, crossChunkSecondPasses, threadProcessors, region, finished);
this.proxyLevel = PaperweightLevelProxy.getInstance(serverLevel, this); this.proxyLevel = PaperweightLevelProxy.getInstance(serverLevel, this);
this.mutableBlockPlaceContext = new FaweMutableBlockPlaceContext(proxyLevel); this.mutableBlockPlaceContext = new PaperweightFaweMutableBlockPlaceContext(proxyLevel);
} }
@Override @Override

Datei anzeigen

@ -1,5 +1,7 @@
package com.fastasyncworldedit.core.extent.processor; package com.fastasyncworldedit.core.extent.processor;
import com.fastasyncworldedit.core.configuration.Caption;
import com.fastasyncworldedit.core.extent.NullExtent;
import com.fastasyncworldedit.core.extent.filter.block.FilterBlock; import com.fastasyncworldedit.core.extent.filter.block.FilterBlock;
import com.fastasyncworldedit.core.function.mask.AdjacentAny2DMask; import com.fastasyncworldedit.core.function.mask.AdjacentAny2DMask;
import com.fastasyncworldedit.core.math.BlockVector3ChunkMap; import com.fastasyncworldedit.core.math.BlockVector3ChunkMap;
@ -9,11 +11,12 @@ import com.fastasyncworldedit.core.queue.IBatchProcessor;
import com.fastasyncworldedit.core.queue.IChunk; import com.fastasyncworldedit.core.queue.IChunk;
import com.fastasyncworldedit.core.queue.IChunkGet; import com.fastasyncworldedit.core.queue.IChunkGet;
import com.fastasyncworldedit.core.queue.IChunkSet; import com.fastasyncworldedit.core.queue.IChunkSet;
import com.fastasyncworldedit.core.registry.state.PropertyKey;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.function.mask.BlockCategoryMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -48,6 +51,7 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
private static volatile boolean SETUP = false; private static volatile boolean SETUP = false;
private static BlockTypeMask DEFAULT_MASK = null; private static BlockTypeMask DEFAULT_MASK = null;
private static BlockTypeMask IN_FIRST_PASS = null;
private static BlockTypeMask REQUIRES_SECOND_PASS = null; private static BlockTypeMask REQUIRES_SECOND_PASS = null;
private static AdjacentAny2DMask ADJACENT_STAIR_MASK = null; private static AdjacentAny2DMask ADJACENT_STAIR_MASK = null;
@ -59,6 +63,7 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
protected final AtomicBoolean finished; protected final AtomicBoolean finished;
private final MutableVector3 clickPos = new MutableVector3(); private final MutableVector3 clickPos = new MutableVector3();
private final MutableBlockVector3 clickedBlock = new MutableBlockVector3(); private final MutableBlockVector3 clickedBlock = new MutableBlockVector3();
private final MutableBlockVector3 placedBlock = new MutableBlockVector3(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
private IChunkGet processChunkGet = null; private IChunkGet processChunkGet = null;
private IChunkSet processChunkSet = null; private IChunkSet processChunkSet = null;
@ -109,7 +114,19 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
} }
private static void setup() { private static void setup() {
REQUIRES_SECOND_PASS = new BlockTypeMask(new NullExtent()); NullExtent nullExtent = new NullExtent(
com.sk89q.worldedit.extent.NullExtent.INSTANCE,
Caption.of("PlacementStateProcessor fell through to null extent")
);
IN_FIRST_PASS = new BlockTypeMask(nullExtent);
IN_FIRST_PASS.add(
BlockTypes.CHEST,
BlockTypes.TRAPPED_CHEST
);
IN_FIRST_PASS.add(BlockCategories.STAIRS.getAll());
REQUIRES_SECOND_PASS = new BlockTypeMask(nullExtent);
REQUIRES_SECOND_PASS.add( REQUIRES_SECOND_PASS.add(
BlockTypes.IRON_BARS, BlockTypes.IRON_BARS,
BlockTypes.GLASS_PANE, BlockTypes.GLASS_PANE,
@ -164,8 +181,8 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
DEFAULT_MASK.add(category.getAll()); DEFAULT_MASK.add(category.getAll());
} }
} }
BlockTypeMask stairs = new BlockTypeMask(new NullExtent(), BlockCategories.STAIRS.getAll());
ADJACENT_STAIR_MASK = new AdjacentAny2DMask(stairs, false); ADJACENT_STAIR_MASK = new AdjacentAny2DMask(new BlockCategoryMask(nullExtent, BlockCategories.STAIRS), false);
SETUP = true; SETUP = true;
} }
@ -225,13 +242,14 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
int blockX = processChunkX + x; int blockX = processChunkX + x;
char ordinal = set[index]; char ordinal = set[index];
BlockState state = BlockTypesCache.states[ordinal]; BlockState state = BlockTypesCache.states[ordinal];
if (firstPass && !BlockCategories.STAIRS.contains(state)) { if (firstPass && !IN_FIRST_PASS.test(state)) {
continue; continue;
} }
if (!mask.test(state)) { if (!mask.test(state)) {
continue; continue;
} }
if (!firstPass && REQUIRES_SECOND_PASS.test(state)) { boolean atEdge = x == 0 || x == 15 || z == 0 || z == 15;
if (!firstPass && atEdge && REQUIRES_SECOND_PASS.test(state)) {
postCompleteSecondPasses.put(new SecondPass( postCompleteSecondPasses.put(new SecondPass(
blockX, blockX,
blockY, blockY,
@ -241,6 +259,11 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
set[index] = BlockTypesCache.ReservedIDs.__RESERVED__; set[index] = BlockTypesCache.ReservedIDs.__RESERVED__;
continue; continue;
} }
if (state.getBlockType().equals(BlockTypes.CHEST) || state.getBlockType().equals(BlockTypes.TRAPPED_CHEST)) {
placedBlock.setComponents(blockX, blockY, blockZ);
} else {
placedBlock.setComponents(Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
}
char newOrdinal = getBlockOrdinal(blockX, blockY, blockZ, state); char newOrdinal = getBlockOrdinal(blockX, blockY, blockZ, state);
if (newOrdinal == ordinal) { if (newOrdinal == ordinal) {
continue; continue;
@ -313,6 +336,28 @@ public abstract class PlacementStateProcessor extends AbstractDelegateExtent imp
if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) { if (ordinal == BlockTypesCache.ReservedIDs.__RESERVED__) {
return processChunkGet.getBlock(x & 15, y, z & 15); return processChunkGet.getBlock(x & 15, y, z & 15);
} }
BlockState state = BlockTypesCache.states[ordinal];
// "Hack" for stairs as internal server methods will only accept "single" chests for joining
if (state.getBlockType().equals(BlockTypes.CHEST) || state.getBlockType().equals(BlockTypes.TRAPPED_CHEST)) {
String shape = state.getState(PropertyKey.TYPE).toString();
if (shape.equals("right")) {
Direction facing = state.getState(PropertyKey.FACING);
Direction left = facing.getLeft();
int testX = x + left.getBlockX();
int testZ = z + left.getBlockZ();
if (placedBlock.isAt(testX, y, testZ)) {
return state.with(PropertyKey.TYPE, "single");
}
} else if(shape.equals("left")) {
Direction facing = state.getState(PropertyKey.FACING);
Direction right = facing.getRight();
int testX = x + right.getBlockX();
int testZ = z + right.getBlockZ();
if (placedBlock.isAt(testX, y, testZ)) {
return state.with(PropertyKey.TYPE, "single");
}
}
}
return BlockTypesCache.states[ordinal]; return BlockTypesCache.states[ordinal];
} }

Datei anzeigen

@ -22,6 +22,7 @@ package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockCategory;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable; import javax.annotation.Nullable;
@ -54,6 +55,15 @@ public class BlockCategoryMask extends AbstractExtentMask {
public boolean test(Extent extent, BlockVector3 vector) { public boolean test(Extent extent, BlockVector3 vector) {
return category.contains(extent.getBlock(vector)); return category.contains(extent.getBlock(vector));
} }
/**
* Test a specific block against this category mask
*
* @since TODO
*/
public <B extends BlockStateHolder<B>> boolean test(B blockStateHolder) {
return category.contains(blockStateHolder);
}
//FAWE end //FAWE end
@Nullable @Nullable

Datei anzeigen

@ -127,6 +127,10 @@ public abstract class BlockVector3 {
} }
//FAWE start //FAWE start
public boolean isAt(int x, int y, int z) {
return x() == x && y() == y && z() == z;
}
public MutableBlockVector3 setComponents(double x, double y, double z) { public MutableBlockVector3 setComponents(double x, double y, double z) {
return new MutableBlockVector3((int) x, (int) y, (int) z); return new MutableBlockVector3((int) x, (int) y, (int) z);
} }

Datei anzeigen

@ -19,7 +19,6 @@
package com.sk89q.worldedit.util; package com.sk89q.worldedit.util;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import java.util.Arrays; import java.util.Arrays;
@ -31,7 +30,12 @@ import java.util.stream.Collectors;
public class SideEffectSet { public class SideEffectSet {
private static final SideEffectSet DEFAULT = new SideEffectSet(); //FAWE start - assign value map
private static final SideEffectSet DEFAULT = new SideEffectSet(
Arrays.stream(SideEffect.values())
.filter(SideEffect::isExposed)
.collect(Collectors.toMap(Function.identity(), SideEffect::getDefaultValue)));
//FAWE end
private static final SideEffectSet NONE = new SideEffectSet( private static final SideEffectSet NONE = new SideEffectSet(
Arrays.stream(SideEffect.values()) Arrays.stream(SideEffect.values())
.filter(SideEffect::isExposed) .filter(SideEffect::isExposed)
@ -42,12 +46,6 @@ public class SideEffectSet {
private final Set<SideEffect> appliedSideEffects; private final Set<SideEffect> appliedSideEffects;
private final boolean appliesAny; private final boolean appliesAny;
//FAWE start
private SideEffectSet() {
this(ImmutableMap.of());
}
//FAWE end
public SideEffectSet(Map<SideEffect, SideEffect.State> sideEffects) { public SideEffectSet(Map<SideEffect, SideEffect.State> sideEffects) {
this.sideEffects = Maps.immutableEnumMap(sideEffects); this.sideEffects = Maps.immutableEnumMap(sideEffects);