minecraft-source/src/net/minecraft/world/level/block/SkullBlock.java

73 lines
2.9 KiB
Java

package net.minecraft.world.level.block;
import net.minecraft.world.level.block.state.AbstractStateHolder;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.util.Mth;
import net.minecraft.world.item.BlockPlaceContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.level.block.state.properties.IntegerProperty;
public class SkullBlock extends AbstractSkullBlock {
public static final IntegerProperty ROTATION;
protected static final VoxelShape SHAPE;
protected SkullBlock(final Type a, final Properties c) {
super(a, c);
this.registerDefaultState(((AbstractStateHolder<O, BlockState>)this.stateDefinition.any()).<Comparable, Integer>setValue((Property<Comparable>)SkullBlock.ROTATION, 0));
}
@Override
public VoxelShape getShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk, final CollisionContext cvn) {
return SkullBlock.SHAPE;
}
@Override
public VoxelShape getOcclusionShape(final BlockState byg, final BlockGetter bjd, final BlockPos fk) {
return Shapes.empty();
}
@Override
public BlockState getStateForPlacement(final BlockPlaceContext bcn) {
return ((AbstractStateHolder<O, BlockState>)this.defaultBlockState()).<Comparable, Integer>setValue((Property<Comparable>)SkullBlock.ROTATION, Mth.floor(bcn.getRotation() * 16.0f / 360.0f + 0.5) & 0xF);
}
@Override
public BlockState rotate(final BlockState byg, final Rotation btr) {
return ((AbstractStateHolder<O, BlockState>)byg).<Comparable, Integer>setValue((Property<Comparable>)SkullBlock.ROTATION, btr.rotate(byg.<Integer>getValue((Property<Integer>)SkullBlock.ROTATION), 16));
}
@Override
public BlockState mirror(final BlockState byg, final Mirror bsr) {
return ((AbstractStateHolder<O, BlockState>)byg).<Comparable, Integer>setValue((Property<Comparable>)SkullBlock.ROTATION, bsr.mirror(byg.<Integer>getValue((Property<Integer>)SkullBlock.ROTATION), 16));
}
@Override
protected void createBlockStateDefinition(final StateDefinition.Builder<Block, BlockState> a) {
a.add(SkullBlock.ROTATION);
}
static {
ROTATION = BlockStateProperties.ROTATION_16;
SHAPE = Block.box(4.0, 0.0, 4.0, 12.0, 8.0, 12.0);
}
public enum Types implements Type {
SKELETON,
WITHER_SKELETON,
PLAYER,
ZOMBIE,
CREEPER,
DRAGON;
}
public interface Type {
}
}