@Override public BaseBlock toBaseBlock(CompoundTag 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> BaseBlock with(Property<V> property, V value) { return this.blockState.with(property, value).toBaseBlock(getNbtData()); }
private Map<Map<Property<?>, Object>, BlockState> getBlockStatesMap() { return updateField(blockStatesMap, () -> BlockState.generateStateMap(this)); }
/** * Checks whether the type ID and data value are equal. */ @Override public boolean equals(Object o) { if (!(o instanceof BaseBlock)) { if (!hasNbtData() && o instanceof BlockStateHolder) { return Objects.equals(toImmutableState(), ((BlockStateHolder<?>) o).toImmutableState()); } return false; } final BaseBlock otherBlock = (BaseBlock) o; return this.blockState.equalsFuzzy(otherBlock.blockState) && Objects.equals(getNbtData(), otherBlock.getNbtData()); }
@Override public int hashCode() { int ret = toImmutableState().hashCode() << 3; if (hasNbtData()) { ret += getNbtData().hashCode(); } return ret; }
/** * Checks whether the BlockStateHolder is contained within * this category. * * @param blockStateHolder The blockstateholder * @return If it's a part of this category */ public <B extends BlockStateHolder<B>> boolean contains(B blockStateHolder) { return this.getAll().contains(blockStateHolder.getBlockType()); } }
@Override public BaseBlock apply(BlockVector3 pos) { BaseBlock block = buffer.get(pos); if (block != null) { return block; } else { return BlockTypes.AIR.getDefaultState().toBaseBlock(); } }
private static BlockCategory register(final String id) { return register(new BlockCategory(id)); }
public FuzzyBlockState getFuzzyMatcher() { return updateField(emptyFuzzy, () -> new FuzzyBlockState(this)); }
/** * Gets whether this block type has an item representation. * * @return If it has an item */ public boolean hasItemType() { return getItemType() != null; }
/** * Checks if the type is the same, and if the matched states are the same. * * @param o other block * @return true if equal */ @Override public boolean equalsFuzzy(BlockStateHolder<?> o) { return this.blockState.equalsFuzzy(o); }
/** * Gets the State for this Block. * * @param property The state to get the value for * @return The state value */ @Override public <V> V getState(Property<V> property) { return this.blockState.getState(property); }
/** * Gets an instance of a builder. * * @return The builder */ public static Builder builder() { return new Builder(); }
@Override public String toString() { // if (getNbtData() != null) { // TODO Maybe make some JSON serialiser to make this not awful. // return blockState.getAsString() + " {" + String.valueOf(getNbtData()) + "}"; // } else { return blockState.getAsString(); // } }
/** * Gets a map of state to statevalue * * @return The state map */ @Override public Map<Property<?>, Object> getStates() { return this.blockState.getStates(); }
@Override public BaseBlock toBaseBlock(CompoundTag compoundTag) { if (compoundTag == null) { return toBaseBlock(); } return new BaseBlock(this, compoundTag); }
@Override public boolean equals(Object obj) { if (!(obj instanceof BlockState)) { return false; } return equalsFuzzy((BlockState) obj); }