Changes to NBT-handling in operations and extents, changes to match the widely supported setBlock functionality, minor code cleanup

This commit is contained in:
IronApollo
2019-03-25 13:31:12 -04:00
parent 16c22b75da
commit 3236bdd78e
57 changed files with 347 additions and 417 deletions

View File

@ -244,7 +244,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
@Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
return this.toImmutableState().apply(extent, get, set);
return extent.setBlock(set, this);
}
@Override
@ -253,8 +253,8 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
}
@Override
public BlockStateHolder withPropertyId(int propertyId) {
return getBlockType().withPropertyId(propertyId);
public BaseBlock withPropertyId(int propertyId) {
return getBlockType().withPropertyId(propertyId).toBaseBlock(getNbtData());
}
@Override
@ -274,12 +274,12 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
@Override
public <V> BaseBlock with(Property<V> property, V value) {
return toImmutableState().with(property, value).toBaseBlock();
return toImmutableState().with(property, value).toBaseBlock(getNbtData());
}
@Override
public <V> BlockStateHolder with(PropertyKey property, V value) {
return toImmutableState().with(property, value);
public <V> BaseBlock with(PropertyKey property, V value) {
return toImmutableState().with(property, value).toBaseBlock(getNbtData());
}
@Override

View File

@ -19,19 +19,13 @@
package com.sk89q.worldedit.world.block;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.command.SuggestInputParseException;
import com.boydti.fawe.object.string.MutableCharSequence;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.base.Supplier;
import com.google.common.collect.Maps;
import com.google.common.collect.Table;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SingleBlockStateMask;
@ -45,10 +39,7 @@ import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@ -249,27 +240,6 @@ public class BlockState implements BlockStateHolder<BlockState> {
return this.toBaseBlock();
}
@Override
public boolean hasNbtData() {
return getNbtData() != null;
}
@Override
public String getNbtId() {
return "";
}
@Nullable
@Override
public CompoundTag getNbtData() {
return null;
}
@Override
public void setNbtData(@Nullable CompoundTag nbtData) {
throw new UnsupportedOperationException("This class is immutable.");
}
/**
* The internal id with no type information
* @return

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.world.block;
import com.sk89q.worldedit.blocks.TileEntityBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.FawePattern;
@ -31,7 +30,7 @@ import com.sk89q.worldedit.world.registry.BlockMaterial;
import java.util.Map;
import java.util.stream.Collectors;
public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePattern, TileEntityBlock {
public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePattern {
/**
* Get the block type
@ -46,7 +45,7 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
* @return
*/
@Deprecated
BlockStateHolder withPropertyId(int propertyId);
T withPropertyId(int propertyId);
/**
* Get combined id (legacy uses)
@ -91,7 +90,7 @@ public interface BlockStateHolder<T extends BlockStateHolder<T>> extends FawePat
* @param value The value
* @return The modified state, or same if could not be applied
*/
<V> BlockStateHolder with(final PropertyKey property, final V value);
<V> T with(final PropertyKey property, final V value);
/**
* Gets the value at the given state