/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.MapCodec */ package net.minecraft.world.level.block; import com.mojang.math.OctahedralGroup; import com.mojang.serialization.MapCodec; import java.util.Map; import java.util.function.Function; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; import net.minecraft.stats.Stats; import net.minecraft.world.InteractionResult; import net.minecraft.world.MenuProvider; import net.minecraft.world.SimpleMenuProvider; import net.minecraft.world.entity.player.Player; import net.minecraft.world.inventory.ContainerLevelAccess; import net.minecraft.world.inventory.GrindstoneMenu; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock; import net.minecraft.world.level.block.Mirror; 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.AttachFace; import net.minecraft.world.level.pathfinder.PathComputationType; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; public class GrindstoneBlock extends FaceAttachedHorizontalDirectionalBlock { public static final MapCodec CODEC = GrindstoneBlock.simpleCodec(GrindstoneBlock::new); private static final Component CONTAINER_TITLE = Component.translatable("container.grindstone_title"); private final Function shapes; public MapCodec codec() { return CODEC; } protected GrindstoneBlock(BlockBehaviour.Properties properties) { super(properties); this.registerDefaultState((BlockState)((BlockState)((BlockState)this.stateDefinition.any()).setValue(FACING, Direction.NORTH)).setValue(FACE, AttachFace.WALL)); this.shapes = this.makeShapes(); } private Function makeShapes() { VoxelShape leftLegs = Shapes.or(Block.box(2.0, 6.0, 7.0, 4.0, 10.0, 16.0), Block.box(2.0, 5.0, 3.0, 4.0, 11.0, 9.0)); VoxelShape rightLegs = Shapes.rotate(leftLegs, OctahedralGroup.INVERT_X); VoxelShape north = Shapes.or(Block.boxZ(8.0, 2.0, 14.0, 0.0, 12.0), leftLegs, rightLegs); Map> attachFace = Shapes.rotateAttachFace(north); return this.getShapeForEachState(state -> (VoxelShape)((Map)attachFace.get(state.getValue(FACE))).get(state.getValue(FACING))); } private VoxelShape getVoxelShape(BlockState state) { return this.shapes.apply(state); } @Override protected VoxelShape getCollisionShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { return this.getVoxelShape(state); } @Override protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { return this.getVoxelShape(state); } @Override protected boolean canSurvive(BlockState state, LevelReader level, BlockPos pos) { return true; } @Override protected InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, BlockHitResult hitResult) { if (!level.isClientSide()) { player.openMenu(state.getMenuProvider(level, pos)); player.awardStat(Stats.INTERACT_WITH_GRINDSTONE); } return InteractionResult.SUCCESS; } @Override protected MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { return new SimpleMenuProvider((containerId, inventory, player) -> new GrindstoneMenu(containerId, inventory, ContainerLevelAccess.create(level, pos)), CONTAINER_TITLE); } @Override protected BlockState rotate(BlockState state, Rotation rotation) { return (BlockState)state.setValue(FACING, rotation.rotate((Direction)state.getValue(FACING))); } @Override protected BlockState mirror(BlockState state, Mirror mirror) { return state.rotate(mirror.getRotation((Direction)state.getValue(FACING))); } @Override protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(FACING, FACE); } @Override protected boolean isPathfindable(BlockState state, PathComputationType type) { return false; } }