mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-11-16 17:16:11 +00:00
Fix up annotations in block classes and slight cleanup
This commit is contained in:
parent
80d99073ec
commit
ea6b29f145
@ -54,9 +54,7 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
|
||||
private final BlockState blockState;
|
||||
@Nullable
|
||||
//FAWE start - LR<CBT> instead of CompoundTat
|
||||
private final LazyReference<CompoundBinaryTag> nbtData;
|
||||
//FAWE end
|
||||
|
||||
//FAWE start
|
||||
|
||||
@ -167,16 +165,13 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
|
||||
@Override
|
||||
public String getNbtId() {
|
||||
//FAWE start - LR<CBT> > CompoundTag
|
||||
LazyReference<CompoundBinaryTag> nbtData = this.nbtData;
|
||||
if (nbtData == null) {
|
||||
return "";
|
||||
}
|
||||
return nbtData.getValue().getString("id");
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Nullable
|
||||
@Override
|
||||
public LazyReference<CompoundBinaryTag> getNbtReference() {
|
||||
@ -187,7 +182,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
public void setNbtReference(@Nullable LazyReference<CompoundBinaryTag> nbtData) {
|
||||
throw new UnsupportedOperationException("This class is immutable.");
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Checks whether the type ID and data value are equal.
|
||||
@ -249,6 +243,17 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock(LazyReference<CompoundBinaryTag> compoundTag) {
|
||||
if (compoundTag == null) {
|
||||
return this.blockState.toBaseBlock();
|
||||
} else if (compoundTag == this.nbtData) {
|
||||
return this;
|
||||
} else {
|
||||
return new BaseBlock(this.blockState, compoundTag);
|
||||
}
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
@ -284,22 +289,15 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
return toImmutableState().with(property, value).toBaseBlock(getNbtData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock toBaseBlock(LazyReference<CompoundBinaryTag> compoundTag) {
|
||||
if (compoundTag == null) {
|
||||
return this.blockState.toBaseBlock();
|
||||
} else if (compoundTag == this.nbtData) {
|
||||
return this;
|
||||
} else {
|
||||
return new BaseBlock(this.blockState, compoundTag);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <V> V getState(PropertyKey property) {
|
||||
return toImmutableState().getState(property);
|
||||
}
|
||||
|
||||
public BlockState toBlockState() {
|
||||
return blockState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getOrdinal();
|
||||
@ -309,7 +307,6 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
@Override
|
||||
public String toString() {
|
||||
String nbtString = "";
|
||||
//FAWE start - use CBT
|
||||
CompoundBinaryTag nbtData = getNbt();
|
||||
if (nbtData != null) {
|
||||
try {
|
||||
@ -321,9 +318,4 @@ public class BaseBlock implements BlockStateHolder<BaseBlock>, TileEntityBlock {
|
||||
|
||||
return blockState.getAsString() + nbtString;
|
||||
}
|
||||
|
||||
public BlockState toBlockState() {
|
||||
return blockState;
|
||||
}
|
||||
//FAWE end
|
||||
}
|
||||
|
@ -250,11 +250,6 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
return getBlockType().withPropertyId(propertyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getBlockType() {
|
||||
return this.blockType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return set.setBlock(extent, this);
|
||||
@ -338,15 +333,22 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
}
|
||||
return newState;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public Map<Property<?>, Object> getStates() {
|
||||
//FAWE end
|
||||
BlockType type = this.getBlockType();
|
||||
// Lazily initialize the map
|
||||
Map<? extends Property, Object> map = Maps.asMap(type.getPropertiesSet(), (Function<Property, Object>) this::getState);
|
||||
return Collections.unmodifiableMap((Map<Property<?>, Object>) map);
|
||||
return Collections.unmodifiableMap(map);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockType getBlockType() {
|
||||
return this.blockType;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public boolean equalsFuzzy(BlockStateHolder<?> o) {
|
||||
@ -357,10 +359,12 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
// Added a reference equality check for speediness
|
||||
return true;
|
||||
}
|
||||
//FAWE start
|
||||
if (o.getClass() == BlockState.class) {
|
||||
return o.getOrdinal() == this.getOrdinal();
|
||||
}
|
||||
return o.equalsFuzzy(this);
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -431,20 +435,6 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
return this.ordinalChar;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof BlockState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return equalsFuzzy((BlockState) obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getOrdinal();
|
||||
@ -459,4 +449,18 @@ public class BlockState implements BlockStateHolder<BlockState>, Pattern {
|
||||
return compoundInput.get(this, input, x, y, z);
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getAsString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof BlockState)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return equalsFuzzy((BlockState) obj);
|
||||
}
|
||||
}
|
||||
|
@ -92,6 +92,15 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
*/
|
||||
<V> B with(final Property<V> property, final V value);
|
||||
|
||||
/**
|
||||
* Gets the value for the given state.
|
||||
*
|
||||
* @param property The state
|
||||
* @return The value
|
||||
*/
|
||||
<V> V getState(Property<V> property);
|
||||
|
||||
//FAWE start
|
||||
/**
|
||||
* Returns a BlockStateHolder with the given state and value applied.
|
||||
*
|
||||
@ -101,14 +110,6 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
*/
|
||||
<V> B with(final PropertyKey property, final V value);
|
||||
|
||||
/**
|
||||
* Gets the value for the given state.
|
||||
*
|
||||
* @param property The state
|
||||
* @return The value
|
||||
*/
|
||||
<V> V getState(Property<V> property);
|
||||
|
||||
/**
|
||||
* Gets the value for the given state.
|
||||
*
|
||||
@ -116,6 +117,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
* @return The value
|
||||
*/
|
||||
<V> V getState(final PropertyKey property);
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Gets an immutable collection of the states.
|
||||
@ -146,8 +148,6 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
*/
|
||||
BaseBlock toBaseBlock();
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
* Gets a {@link BaseBlock} from this BlockStateHolder.
|
||||
*
|
||||
@ -193,6 +193,7 @@ public interface BlockStateHolder<B extends BlockStateHolder<B>> extends TileEnt
|
||||
return toBaseBlock();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
void applyTileEntity(OutputExtent output, int x, int y, int z);
|
||||
|
||||
default BaseBlock toBaseBlock(ITileInput input, int x, int y, int z) {
|
||||
|
@ -60,17 +60,15 @@ public class BlockType implements Keyed, Pattern {
|
||||
private static final Logger LOGGER = LogManagerCompat.getLogger();
|
||||
|
||||
private final String id;
|
||||
private final BlockTypesCache.Settings settings;
|
||||
private final LazyReference<FuzzyBlockState> emptyFuzzy
|
||||
= LazyReference.from(() -> new FuzzyBlockState(this));
|
||||
//FAWE start
|
||||
private final BlockTypesCache.Settings settings;
|
||||
@Deprecated
|
||||
private final LazyReference<String> name = LazyReference.from(() -> WorldEdit.getInstance().getPlatformManager()
|
||||
.queryCapability(Capability.GAME_HOOKS).getRegistries().getBlockRegistry().getName(this));
|
||||
|
||||
//FAWE start
|
||||
private final LazyReference<Integer> legacyId = LazyReference.from(() -> computeLegacy(0));
|
||||
private final LazyReference<Integer> legacyData = LazyReference.from(() -> computeLegacy(1));
|
||||
|
||||
private Integer legacyCombinedId;
|
||||
private boolean initItemType;
|
||||
private ItemType itemType;
|
||||
@ -382,6 +380,11 @@ public class BlockType implements Keyed, Pattern {
|
||||
//FAWE end
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
|
||||
/**
|
||||
@ -397,11 +400,6 @@ public class BlockType implements Keyed, Pattern {
|
||||
return this.settings.internalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return settings.internalId; // stop changing this to WEs bad hashcode
|
||||
|
@ -37,16 +37,16 @@ public class BlockTypesCache {
|
||||
*/
|
||||
protected static final class Settings {
|
||||
|
||||
protected final int internalId;
|
||||
protected final BlockState defaultState;
|
||||
protected final AbstractProperty<?>[] propertiesMapArr;
|
||||
protected final AbstractProperty<?>[] propertiesArr;
|
||||
protected final List<AbstractProperty<?>> propertiesList;
|
||||
protected final Map<String, AbstractProperty<?>> propertiesMap;
|
||||
protected final Set<AbstractProperty<?>> propertiesSet;
|
||||
protected final BlockMaterial blockMaterial;
|
||||
protected final int permutations;
|
||||
protected int[] stateOrdinals;
|
||||
final int internalId;
|
||||
final BlockState defaultState;
|
||||
final AbstractProperty<?>[] propertiesMapArr;
|
||||
final AbstractProperty<?>[] propertiesArr;
|
||||
final List<AbstractProperty<?>> propertiesList;
|
||||
final Map<String, AbstractProperty<?>> propertiesMap;
|
||||
final Set<AbstractProperty<?>> propertiesSet;
|
||||
final BlockMaterial blockMaterial;
|
||||
final int permutations;
|
||||
int[] stateOrdinals;
|
||||
|
||||
Settings(BlockType type, String id, int internalId, List<BlockState> states) {
|
||||
this.internalId = internalId;
|
||||
|
@ -52,8 +52,8 @@ public class FuzzyBlockState extends BlockState {
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
//FAWE start - use internal ids
|
||||
private FuzzyBlockState(BlockState state, Map<Property<?>, Object> values) {
|
||||
//FAWE start - use internal ids
|
||||
super(state.getBlockType(), state.getInternalId(), state.getOrdinal());
|
||||
if (values == null || values.isEmpty()) {
|
||||
props = Collections.emptyMap();
|
||||
@ -65,9 +65,8 @@ public class FuzzyBlockState extends BlockState {
|
||||
}
|
||||
this.values = new HashMap<>(values);
|
||||
}
|
||||
|
||||
//FAWE end
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Gets a full BlockState from this fuzzy one, filling in
|
||||
@ -85,6 +84,11 @@ public class FuzzyBlockState extends BlockState {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState toImmutableState() {
|
||||
return getFullState();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Override
|
||||
public boolean equalsFuzzy(BlockStateHolder<?> o) {
|
||||
@ -113,15 +117,16 @@ public class FuzzyBlockState extends BlockState {
|
||||
return new BaseBlock(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState toImmutableState() {
|
||||
return getFullState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Property<?>, Object> getStates() {
|
||||
return values;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
return getBlockType().getMaterial().isTile() ? getBlockType().getMaterial().getDefaultTile() : null;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
@ -133,14 +138,6 @@ public class FuzzyBlockState extends BlockState {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
//FAWE start
|
||||
@Deprecated
|
||||
@Override
|
||||
public CompoundTag getNbtData() {
|
||||
return getBlockType().getMaterial().isTile() ? getBlockType().getMaterial().getDefaultTile() : null;
|
||||
}
|
||||
//FAWE end
|
||||
|
||||
/**
|
||||
* Builder for FuzzyBlockState
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user