Selective upstream merge

Signed-off-by: MattBDev <4009945+MattBDev@users.noreply.github.com>
This commit is contained in:
MattBDev
2019-06-04 11:48:30 -04:00
parent c73fc28847
commit 6c94cca15e
75 changed files with 1039 additions and 1182 deletions

View File

@ -38,10 +38,7 @@ import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import javax.annotation.Nullable;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@ -124,7 +121,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
String input = key.toString();
throw new SuggestInputParseException("Does not match a valid block type: " + input, input, () -> Stream.of(BlockTypes.values)
.filter(b -> StringMan.blockStateMatches(input, b.getId()))
.map(e1 -> e1.getId())
.map(BlockType::getId)
.sorted(StringMan.blockStateComparator(input))
.collect(Collectors.toList())
);
@ -181,12 +178,12 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
BlockType finalType = type;
throw new SuggestInputParseException("Invalid property " + charSequence + ":" + input + " for type " + type, input, () ->
finalType.getProperties().stream()
.map(p -> p.getName())
.map(Property::getName)
.filter(p -> StringMan.blockStateMatches(input, p))
.sorted(StringMan.blockStateComparator(input))
.collect(Collectors.toList()));
} else {
throw new SuggestInputParseException("No operator for " + state, "", () -> Arrays.asList("="));
throw new SuggestInputParseException("No operator for " + state, "", () -> Collections.singletonList("="));
}
}
property = null;
@ -211,6 +208,11 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
return getBlockType().withPropertyId(propertyId);
}
@Override
public BlockType getBlockType() {
return this.blockType;
}
@Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
return extent.setBlock(set, this);
@ -259,6 +261,14 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
}
}
@Override
public final Map<Property<?>, Object> getStates() {
BlockType type = this.getBlockType();
// Lazily initialize the map
Map<? extends Property, Object> map = Maps.asMap(type.getPropertiesSet(), (Function<Property, Object>) this::getState);
return (Map<Property<?>, Object>) map;
}
@Override
public final <V> V getState(final Property<V> property) {
try {
@ -269,19 +279,9 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
}
}
@Deprecated
@Override
public final <V> V getState(final PropertyKey key) {
return getState(getBlockType().getProperty(key));
}
@Override
@Deprecated
public final Map<Property<?>, Object> getStates() {
BlockType type = this.getBlockType();
// Lazily initialize the map
Map<? extends Property, Object> map = Maps.asMap(type.getPropertiesSet(), (Function<Property, Object>) input -> getState(input));
return (Map<Property<?>, Object>) map;
public BlockState toImmutableState() {
return this;
}
@Override
@ -289,6 +289,12 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
return this.emptyBaseBlock;
}
@Deprecated
@Override
public final <V> V getState(final PropertyKey key) {
return getState(getBlockType().getProperty(key));
}
@Override
public BaseBlock toBaseBlock(CompoundTag compoundTag) {
if (compoundTag == null) {
@ -296,11 +302,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
}
return new BaseBlock(this, compoundTag);
}
@Override
public BlockType getBlockType() {
return this.blockType;
}
@Override
public boolean equalsFuzzy(BlockStateHolder<?> o) {
@ -310,11 +311,6 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
return o.equalsFuzzy(this);
}
@Override
public BlockState toImmutableState() {
return this;
}
@Override
public int getInternalId() {
return internalId;
@ -326,9 +322,7 @@ public class BlockState implements BlockStateHolder<BlockState>, FawePattern {
if (blockType == BlockTypes.__RESERVED__) {
return this.material = blockType.getMaterial();
}
if (this.material == null) {
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
}
this.material = WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getMaterial(this);
}
return material;
}

View File

@ -19,41 +19,31 @@
package com.sk89q.worldedit.world.block;
import static com.google.common.base.Preconditions.checkArgument;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.command.SuggestInputParseException;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.ReflectionUtils;
import com.boydti.fawe.util.StringMan;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
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.SingleBlockTypeMask;
import com.sk89q.worldedit.math.BlockVector3;
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.util.Direction;
import com.sk89q.worldedit.world.item.ItemType;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.registry.BlockMaterial;
import com.sk89q.worldedit.world.registry.BundledBlockData;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import it.unimi.dsi.fastutil.ints.IntCollections;
import javax.annotation.Nullable;
import java.lang.reflect.Field;
import java.util.*;
import java.util.function.Function;
import java.util.function.IntPredicate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
/**