Davey?
This commit is contained in:
parent
0bf6453e69
commit
83a976ae8b
26 changed files with 731 additions and 16 deletions
|
@ -59,16 +59,6 @@ public class GoldenTableLampBlock extends LampBlock {
|
|||
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
|
||||
}
|
||||
|
||||
public VoxelShape getStandingShape(){
|
||||
VoxelShape shape = VoxelShapes.empty();
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.4375, 0.25, 0.4375, 0.5625, 0.875, 0.5625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.375, 0, 0.375, 0.625, 0.25, 0.625));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.25, 0.6875, 0.25, 0.75, 0.9375, 0.75));
|
||||
shape = VoxelShapes.union(shape, VoxelShapes.cuboid(0.125, 0.3125, 0.125, 0.875, 0.6875, 0.875));
|
||||
shape.simplify();
|
||||
return shape;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
return super.getPlacementState(ctx).with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
package su.a71.new_soviet.blocks.lamps.lamp_post;
|
||||
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.ai.pathing.NavigationType;
|
||||
import net.minecraft.fluid.FluidState;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.state.StateManager;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.DirectionProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.state.property.Property;
|
||||
import net.minecraft.util.BlockMirror;
|
||||
import net.minecraft.util.BlockRotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.WorldView;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import su.a71.new_soviet.util.Shapes;
|
||||
|
||||
public class LampPostLampBlock extends Block implements Waterloggable {
|
||||
public static final DirectionProperty FACING;
|
||||
public static final BooleanProperty WATERLOGGED;
|
||||
public Shapes.HorizontalShape SHAPE;
|
||||
|
||||
public LampPostLampBlock(AbstractBlock.Settings settings, Shapes.HorizontalShape shape) {
|
||||
super(settings.luminance((state) -> 14));
|
||||
SHAPE = shape;
|
||||
this.setDefaultState(this.stateManager.getDefaultState()
|
||||
.with(WATERLOGGED, false)
|
||||
.with(Properties.HORIZONTAL_FACING, Direction.NORTH));
|
||||
|
||||
}
|
||||
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
|
||||
Direction dir = state.get(FACING);
|
||||
return switch (dir) {
|
||||
case NORTH -> SHAPE.north();
|
||||
case SOUTH -> SHAPE.south();
|
||||
case EAST -> SHAPE.east();
|
||||
case WEST -> SHAPE.west();
|
||||
default -> VoxelShapes.fullCube();
|
||||
};
|
||||
}
|
||||
|
||||
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
|
||||
Direction direction = Direction.DOWN;
|
||||
return Block.sideCoversSmallSquare(world, pos.offset(direction), direction.getOpposite());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||
FluidState fluidState = ctx.getWorld().getFluidState(ctx.getBlockPos());
|
||||
Direction[] directions = ctx.getPlacementDirections();
|
||||
for (Direction direction : directions) {
|
||||
if (direction.getAxis() == Direction.Axis.Y) {
|
||||
BlockState blockState = this.getDefaultState();
|
||||
if (blockState.canPlaceAt(ctx.getWorld(), ctx.getBlockPos())) {
|
||||
return blockState
|
||||
.with(WATERLOGGED, fluidState.getFluid() == Fluids.WATER)
|
||||
.with(Properties.HORIZONTAL_FACING, ctx.getHorizontalPlayerFacing().getOpposite());
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||
builder.add(new Property[]{WATERLOGGED, Properties.HORIZONTAL_FACING});
|
||||
}
|
||||
|
||||
public BlockState getStateForNeighborUpdate(BlockState state, Direction direction, BlockState neighborState, WorldAccess world, BlockPos pos, BlockPos neighborPos) {
|
||||
if (state.get(WATERLOGGED)) {
|
||||
world.scheduleFluidTick(pos, Fluids.WATER, Fluids.WATER.getTickRate(world));
|
||||
}
|
||||
|
||||
return !state.canPlaceAt(world, pos) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(state, direction, neighborState, world, pos, neighborPos);
|
||||
}
|
||||
|
||||
public FluidState getFluidState(BlockState state) {
|
||||
return state.get(WATERLOGGED) ? Fluids.WATER.getStill(false) : super.getFluidState(state);
|
||||
}
|
||||
|
||||
public boolean canPathfindThrough(BlockState state, BlockView world, BlockPos pos, NavigationType type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||
return (BlockState)state.with(FACING, rotation.rotate((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
public BlockState mirror(BlockState state, BlockMirror mirror) {
|
||||
return state.rotate(mirror.getRotation((Direction)state.get(FACING)));
|
||||
}
|
||||
|
||||
static {
|
||||
WATERLOGGED = Properties.WATERLOGGED;
|
||||
FACING = Properties.HORIZONTAL_FACING;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue