68 lines
2.3 KiB
Java
68 lines
2.3 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.serialization.MapCodec
|
|
*/
|
|
package net.minecraft.world.level.block;
|
|
|
|
import com.mojang.serialization.MapCodec;
|
|
import net.minecraft.core.Direction;
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
|
import net.minecraft.world.level.block.Block;
|
|
import net.minecraft.world.level.block.Rotation;
|
|
import net.minecraft.world.level.block.state.BlockBehaviour;
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.block.state.StateDefinition;
|
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
|
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
|
|
|
public class RotatedPillarBlock
|
|
extends Block {
|
|
public static final MapCodec<RotatedPillarBlock> CODEC = RotatedPillarBlock.simpleCodec(RotatedPillarBlock::new);
|
|
public static final EnumProperty<Direction.Axis> AXIS = BlockStateProperties.AXIS;
|
|
|
|
public MapCodec<? extends RotatedPillarBlock> codec() {
|
|
return CODEC;
|
|
}
|
|
|
|
public RotatedPillarBlock(BlockBehaviour.Properties properties) {
|
|
super(properties);
|
|
this.registerDefaultState((BlockState)this.defaultBlockState().setValue(AXIS, Direction.Axis.Y));
|
|
}
|
|
|
|
@Override
|
|
protected BlockState rotate(BlockState state, Rotation rotation) {
|
|
return RotatedPillarBlock.rotatePillar(state, rotation);
|
|
}
|
|
|
|
public static BlockState rotatePillar(BlockState state, Rotation rotation) {
|
|
switch (rotation) {
|
|
case COUNTERCLOCKWISE_90:
|
|
case CLOCKWISE_90: {
|
|
switch (state.getValue(AXIS)) {
|
|
case X: {
|
|
return (BlockState)state.setValue(AXIS, Direction.Axis.Z);
|
|
}
|
|
case Z: {
|
|
return (BlockState)state.setValue(AXIS, Direction.Axis.X);
|
|
}
|
|
}
|
|
return state;
|
|
}
|
|
}
|
|
return state;
|
|
}
|
|
|
|
@Override
|
|
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
|
|
builder.add(AXIS);
|
|
}
|
|
|
|
@Override
|
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
return (BlockState)this.defaultBlockState().setValue(AXIS, context.getClickedFace().getAxis());
|
|
}
|
|
}
|
|
|