use of org.spongepowered.api.data.manipulator.immutable.block.ImmutableDecayableData in project SpongeCommon by SpongePowered.
the class MixinBlockLeaves method getStateWithData.
@Override
public Optional<BlockState> getStateWithData(IBlockState blockState, ImmutableDataManipulator<?, ?> manipulator) {
if (manipulator instanceof ImmutableTreeData) {
final TreeType treeType = ((ImmutableTreeData) manipulator).type().get();
final BlockPlanks.EnumType type = TreeTypeResolver.getFor(treeType);
if (blockState.getBlock() instanceof BlockOldLeaf) {
if (treeType.equals(TreeTypes.OAK) || treeType.equals(TreeTypes.BIRCH) || treeType.equals(TreeTypes.SPRUCE) || treeType.equals(TreeTypes.JUNGLE)) {
return Optional.of((BlockState) blockState.withProperty(BlockOldLeaf.VARIANT, type));
}
} else if (blockState.getBlock() instanceof BlockNewLeaf) {
if (treeType.equals(TreeTypes.ACACIA) || treeType.equals(TreeTypes.DARK_OAK)) {
return Optional.of((BlockState) blockState.withProperty(BlockNewLeaf.VARIANT, type));
}
}
return Optional.empty();
}
if (manipulator instanceof ImmutableDecayableData) {
final boolean decayable = ((ImmutableDecayableData) manipulator).decayable().get();
return Optional.of((BlockState) blockState.withProperty(BlockLeaves.DECAYABLE, decayable));
}
return super.getStateWithData(blockState, manipulator);
}
Aggregations