mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-05 20:36:42 +00:00
Replace ImmutableBaseBlock with BlanketBaseBlock
- ImmutableBaseBlock is no longer needed as NBT was made immutable previously - BlanketBaseBlock represents to masks that the block has NBT, but does not need to match a specific state - Allow FuzzyBlockState to create BaseBlocks without NBT data (fixed tab completion issues)
This commit is contained in:
@ -0,0 +1,33 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.OutputExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* BaseBlock that when parsed to masks represents all BlockStates of a BlockType, whilst allowing for NBT storage
|
||||
*/
|
||||
public final class BlanketBaseBlock extends BaseBlock {
|
||||
|
||||
public BlanketBaseBlock(BlockState blockState) {
|
||||
super(blockState);
|
||||
}
|
||||
|
||||
public BlanketBaseBlock(BlockState blockState, @NotNull CompoundTag tile) {
|
||||
super(blockState, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock(CompoundTag compoundTag) {
|
||||
if (compoundTag != null) {
|
||||
return new BaseBlock(this.toImmutableState(), compoundTag);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
@ -41,6 +41,7 @@ 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.registry.BlockMaterial;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -62,12 +63,20 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
private final BaseBlock emptyBaseBlock;
|
||||
private CompoundInput compoundInput = CompoundInput.NULL;
|
||||
|
||||
protected BlockState(BlockType blockType, int internalId, int ordinal, CompoundTag tile) {
|
||||
protected BlockState(BlockType blockType, int internalId, int ordinal) {
|
||||
this.blockType = blockType;
|
||||
this.internalId = internalId;
|
||||
this.ordinal = ordinal;
|
||||
this.ordinalChar = (char) ordinal;
|
||||
this.emptyBaseBlock = new ImmutableBaseBlock(this, tile);
|
||||
this.emptyBaseBlock = new BlanketBaseBlock(this);
|
||||
}
|
||||
|
||||
protected BlockState(BlockType blockType, int internalId, int ordinal, @NotNull CompoundTag tile) {
|
||||
this.blockType = blockType;
|
||||
this.internalId = internalId;
|
||||
this.ordinal = ordinal;
|
||||
this.ordinalChar = (char) ordinal;
|
||||
this.emptyBaseBlock = new BlanketBaseBlock(this, tile);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ public class FuzzyBlockState extends BlockState {
|
||||
}
|
||||
|
||||
private FuzzyBlockState(BlockState state, Map<Property<?>, Object> values) {
|
||||
super(state.getBlockType(), state.getInternalId(), state.getOrdinal(), null);
|
||||
super(state.getBlockType(), state.getInternalId(), state.getOrdinal());
|
||||
if (values == null || values.isEmpty()) {
|
||||
props = Collections.emptyMap();
|
||||
this.values = Collections.emptyMap();
|
||||
|
@ -1,58 +0,0 @@
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.extent.OutputExtent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.registry.state.Property;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ImmutableBaseBlock extends BaseBlock {
|
||||
public ImmutableBaseBlock(BlockState blockState) {
|
||||
super(blockState);
|
||||
}
|
||||
public ImmutableBaseBlock(BlockState blockState, CompoundTag tile) {
|
||||
super(blockState, tile);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
return getBlockType().getMaterial().isTile() ? getBlockType().getMaterial().getDefaultTile() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNbtData() {
|
||||
return getBlockType().getMaterial().isTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return set.setBlock(extent, toBlockState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyTileEntity(OutputExtent output, int x, int y, int z) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> BaseBlock with(Property<V> property, V value) {
|
||||
return toImmutableState().with(property, value).toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock(CompoundTag compoundTag) {
|
||||
if (compoundTag != null) {
|
||||
return new BaseBlock(this.toImmutableState(), compoundTag);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user