mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
.
This commit is contained in:
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.world;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
@ -64,7 +65,7 @@ public abstract class AbstractWorld implements World {
|
||||
|
||||
@Override
|
||||
public Mask createLiquidMask() {
|
||||
return new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
|
||||
return new BlockMask(this).add(BlockTypes.LAVA, BlockTypes.WATER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,12 +83,12 @@ public class NullWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
return BiomeTypes.THE_VOID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -134,13 +134,18 @@ public class NullWorld extends AbstractWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return BlockTypes.AIR.getDefaultState();
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
return getBlock(position);
|
||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||
return EditSession.nullBlock.toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +60,7 @@ public interface SimpleWorld extends World {
|
||||
|
||||
@Override
|
||||
default BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return getLazyBlock(position).toBaseBlock();
|
||||
return getBlock(position).toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,7 +73,7 @@ public interface SimpleWorld extends World {
|
||||
|
||||
@Override
|
||||
default Mask createLiquidMask() {
|
||||
return new BlockTypeMask(this, BlockTypes.LAVA, BlockTypes.WATER);
|
||||
return new BlockMask(this).add(BlockTypes.LAVA, BlockTypes.WATER);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -94,7 +94,9 @@ public interface World extends Extent {
|
||||
* @param notifyAndLight true to to notify and light
|
||||
* @return true if the block was successfully set (return value may not be accurate)
|
||||
*/
|
||||
<B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException;
|
||||
default <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
|
||||
return setBlock(position, block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Notifies the simulation that the block at the given location has
|
||||
|
@ -135,20 +135,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
||||
this(other.toImmutableState(), other.getNbtData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
CompoundTag nbtData = getNbtData();
|
||||
if (nbtData == null) {
|
||||
return "";
|
||||
}
|
||||
Tag idTag = nbtData.getValue().get("id");
|
||||
if (idTag instanceof StringTag) {
|
||||
return ((StringTag) idTag).getValue();
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
@ -247,14 +233,10 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return extent.setBlock(set, this);
|
||||
set.setFullBlock(extent, this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(FilterBlock block) {
|
||||
block.setFullBlock(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNbtData() {
|
||||
return this.nbtData != null;
|
||||
|
@ -50,7 +50,7 @@ import java.util.stream.Stream;
|
||||
* An immutable class that represents the state a block can be in.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
public final class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
private final int internalId;
|
||||
private final int ordinal;
|
||||
private final char ordinalChar;
|
||||
@ -216,12 +216,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return extent.setBlock(set, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void apply(FilterBlock block) {
|
||||
block.setOrdinal(ordinal);
|
||||
return set.setBlock(extent, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -267,6 +262,24 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
}
|
||||
}
|
||||
|
||||
public <V> BlockState withProperties(final BlockState other) {
|
||||
BlockType ot = other.getBlockType();
|
||||
if (ot == blockType) {
|
||||
return other;
|
||||
}
|
||||
if (ot.getProperties().isEmpty() || blockType.getProperties().isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
BlockState newState = this;
|
||||
for (Property<?> prop: ot.getProperties()) {
|
||||
PropertyKey key = prop.getKey();
|
||||
if (blockType.hasProperty(key)) {
|
||||
newState = newState.with(key, other.getState(key));
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final <V> V getState(final Property<V> property) {
|
||||
try {
|
||||
|
@ -21,8 +21,6 @@ package com.sk89q.worldedit.world.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.boydti.fawe.util.ReflectionUtils;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.mask.Mask;
|
||||
@ -33,14 +31,12 @@ import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.registry.NamespacedRegistry;
|
||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||
import com.sk89q.worldedit.world.item.ItemType;
|
||||
import com.sk89q.worldedit.world.registry.LegacyMapper;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -299,7 +295,7 @@ public final class BlockType implements FawePattern {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return extent.setBlock(set, this.getDefaultState());
|
||||
return set.setBlock(extent, getDefaultState());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -307,11 +303,6 @@ public final class BlockType implements FawePattern {
|
||||
return this.getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void apply(FilterBlock block) {
|
||||
block.setOrdinal(getDefaultState().getOrdinal());
|
||||
}
|
||||
|
||||
public Mask toMask(Extent extent) {
|
||||
return new SingleBlockTypeMask(extent, this);
|
||||
}
|
||||
|
@ -2,6 +2,9 @@ package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@ -22,7 +25,7 @@ public final class ImmutableBaseBlock extends BaseBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void apply(FilterBlock block) {
|
||||
block.setOrdinal(getOrdinal());
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return set.setBlock(extent, toBlockState());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user