mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 12:06:41 +00:00
wip on 1.14
This commit is contained in:
@ -45,9 +45,8 @@ import java.util.Objects;
|
||||
* may be missing.</p>
|
||||
*/
|
||||
public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
||||
|
||||
private BlockState blockState;
|
||||
@Nullable protected CompoundTag nbtData;
|
||||
private final BlockState blockState;
|
||||
private final CompoundTag nbtData;
|
||||
|
||||
@Deprecated
|
||||
public BaseBlock() {
|
||||
@ -70,6 +69,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
||||
*/
|
||||
public BaseBlock(BlockState blockState) {
|
||||
this.blockState = blockState;
|
||||
nbtData = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -180,7 +180,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
||||
|
||||
@Override
|
||||
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||
this.nbtData = nbtData;
|
||||
throw new UnsupportedOperationException("Immutable");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -232,7 +232,12 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock() {
|
||||
public final char getOrdinalChar() {
|
||||
return blockState.getOrdinalChar();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BaseBlock toBaseBlock() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -247,6 +252,10 @@ public class BaseBlock implements BlockStateHolder<BaseBlock> {
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState toBlockState() {
|
||||
return blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getOrdinal();
|
||||
@ -254,7 +263,8 @@ 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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,6 +19,7 @@
|
||||
|
||||
package com.sk89q.worldedit.world.block;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.boydti.fawe.command.SuggestInputParseException;
|
||||
import com.boydti.fawe.object.string.MutableCharSequence;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
@ -49,6 +50,7 @@ import java.util.stream.Stream;
|
||||
public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
private final int internalId;
|
||||
private final int ordinal;
|
||||
private final char ordinalChar;
|
||||
private final BlockType blockType;
|
||||
private BlockMaterial material;
|
||||
private BaseBlock emptyBaseBlock;
|
||||
@ -57,7 +59,8 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
this.blockType = blockType;
|
||||
this.internalId = internalId;
|
||||
this.ordinal = ordinal;
|
||||
this.emptyBaseBlock = new BaseBlock(this);
|
||||
this.ordinalChar = (char) ordinal;
|
||||
this.emptyBaseBlock = new ImmutableBaseBlock(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -215,7 +218,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);
|
||||
return set.setBlock(extent, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -261,6 +264,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 Map<Property<?>, Object> getStates() {
|
||||
BlockType type = this.getBlockType();
|
||||
@ -327,10 +348,15 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
|
||||
return material;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrdinal() {
|
||||
return this.ordinal;
|
||||
}
|
||||
@Override
|
||||
public final int getOrdinal() {
|
||||
return this.ordinal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final char getOrdinalChar() {
|
||||
return this.ordinalChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
@ -64,6 +64,9 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends FawePat
|
||||
@Deprecated
|
||||
int getOrdinal();
|
||||
|
||||
@Deprecated
|
||||
char getOrdinalChar();
|
||||
|
||||
BlockMaterial getMaterial();
|
||||
/**
|
||||
* Get type id (legacy uses)
|
||||
|
@ -21,7 +21,6 @@ package com.sk89q.worldedit.world.block;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
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 +32,12 @@ import com.sk89q.worldedit.registry.Keyed;
|
||||
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;
|
||||
@ -181,10 +178,15 @@ public class BlockType implements FawePattern, Keyed {
|
||||
*
|
||||
* @return The default state
|
||||
*/
|
||||
public BlockState getDefaultState() {
|
||||
public final BlockState getDefaultState() {
|
||||
return this.settings.defaultState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Deprecated use a Mask instead
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public FuzzyBlockState getFuzzyMatcher() { //
|
||||
return new FuzzyBlockState(this);
|
||||
}
|
||||
@ -296,7 +298,7 @@ public class BlockType implements FawePattern, Keyed {
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return extent.setBlock(set, this.getDefaultState());
|
||||
return set.setBlock(extent, getDefaultState());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,6 +52,10 @@ import java.util.stream.Stream;
|
||||
public final class BlockTypes {
|
||||
// Doesn't really matter what the hardcoded values are, as FAWE will update it on load
|
||||
@Nullable public static final BlockType __RESERVED__ = null;
|
||||
@Nullable public static final BlockType AIR = null;
|
||||
@Nullable public static final BlockType CAVE_AIR = null;
|
||||
@Nullable public static final BlockType VOID_AIR = null;
|
||||
|
||||
@Nullable public static final BlockType ACACIA_BUTTON = null;
|
||||
@Nullable public static final BlockType ACACIA_DOOR = null;
|
||||
@Nullable public static final BlockType ACACIA_FENCE = null;
|
||||
@ -66,7 +70,6 @@ public final class BlockTypes {
|
||||
@Nullable public static final BlockType ACACIA_TRAPDOOR = null;
|
||||
@Nullable public static final BlockType ACACIA_WOOD = null;
|
||||
@Nullable public static final BlockType ACTIVATOR_RAIL = null;
|
||||
@Nullable public static final BlockType AIR = null;
|
||||
@Nullable public static final BlockType ALLIUM = null;
|
||||
@Nullable public static final BlockType ANDESITE = null;
|
||||
@Nullable public static final BlockType ANVIL = null;
|
||||
@ -150,7 +153,6 @@ public final class BlockTypes {
|
||||
@Nullable public static final BlockType CARROTS = null;
|
||||
@Nullable public static final BlockType CARVED_PUMPKIN = null;
|
||||
@Nullable public static final BlockType CAULDRON = null;
|
||||
@Nullable public static final BlockType CAVE_AIR = null;
|
||||
@Nullable public static final BlockType CHAIN_COMMAND_BLOCK = null;
|
||||
@Nullable public static final BlockType CHEST = null;
|
||||
@Nullable public static final BlockType CHIPPED_ANVIL = null;
|
||||
@ -615,7 +617,6 @@ public final class BlockTypes {
|
||||
@Nullable public static final BlockType TUBE_CORAL_WALL_FAN = null;
|
||||
@Nullable public static final BlockType TURTLE_EGG = null;
|
||||
@Nullable public static final BlockType VINE = null;
|
||||
@Nullable public static final BlockType VOID_AIR = null;
|
||||
@Nullable public static final BlockType WALL_SIGN = null;
|
||||
@Nullable public static final BlockType WALL_TORCH = null;
|
||||
@Nullable public static final BlockType WATER = null;
|
||||
|
@ -0,0 +1,50 @@
|
||||
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 com.sk89q.worldedit.registry.state.Property;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class ImmutableBaseBlock extends BaseBlock {
|
||||
public ImmutableBaseBlock(BlockState blockState) {
|
||||
super(blockState);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNbtData() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return set.setBlock(extent, toBlockState());
|
||||
}
|
||||
|
||||
@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