/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.google.common.collect.ImmutableMap * com.google.common.collect.Maps * com.mojang.serialization.MapCodec */ package net.minecraft.world.level.block; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Maps; 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.world.level.BlockGetter; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.state.BlockBehaviour; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.block.state.properties.BooleanProperty; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; public abstract class PipeBlock extends Block { public static final BooleanProperty NORTH = BlockStateProperties.NORTH; public static final BooleanProperty EAST = BlockStateProperties.EAST; public static final BooleanProperty SOUTH = BlockStateProperties.SOUTH; public static final BooleanProperty WEST = BlockStateProperties.WEST; public static final BooleanProperty UP = BlockStateProperties.UP; public static final BooleanProperty DOWN = BlockStateProperties.DOWN; public static final Map PROPERTY_BY_DIRECTION = ImmutableMap.copyOf((Map)Maps.newEnumMap(Map.of(Direction.NORTH, NORTH, Direction.EAST, EAST, Direction.SOUTH, SOUTH, Direction.WEST, WEST, Direction.UP, UP, Direction.DOWN, DOWN))); private final Function shapes; protected PipeBlock(float size, BlockBehaviour.Properties properties) { super(properties); this.shapes = this.makeShapes(size); } protected abstract MapCodec codec(); private Function makeShapes(float size) { VoxelShape core = Block.cube(size); Map shapes = Shapes.rotateAll(Block.boxZ(size, 0.0, 8.0)); return this.getShapeForEachState(state -> { VoxelShape shape = core; for (Map.Entry entry : PROPERTY_BY_DIRECTION.entrySet()) { if (!((Boolean)state.getValue(entry.getValue())).booleanValue()) continue; shape = Shapes.or((VoxelShape)shapes.get(entry.getKey()), shape); } return shape; }); } @Override protected boolean propagatesSkylightDown(BlockState state) { return false; } @Override protected VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) { return this.shapes.apply(state); } }