2022-02-08 01:49:35 +01:00
|
|
|
package com.simibubi.create.content.curiosities.girder;
|
|
|
|
|
2022-07-03 16:34:35 +02:00
|
|
|
import static net.minecraft.world.level.block.FaceAttachedHorizontalDirectionalBlock.FACE;
|
2022-02-08 01:49:35 +01:00
|
|
|
import static net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED;
|
|
|
|
|
2022-02-09 21:13:33 +01:00
|
|
|
import java.util.Random;
|
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
import com.simibubi.create.AllBlocks;
|
2022-06-04 01:54:19 +02:00
|
|
|
import com.simibubi.create.AllItems;
|
2022-02-08 01:49:35 +01:00
|
|
|
import com.simibubi.create.AllShapes;
|
2023-05-09 18:23:47 +02:00
|
|
|
import com.simibubi.create.AllTags;
|
2022-02-09 02:05:48 +01:00
|
|
|
import com.simibubi.create.content.contraptions.base.KineticTileEntity;
|
|
|
|
import com.simibubi.create.content.contraptions.fluids.pipes.BracketBlock;
|
|
|
|
import com.simibubi.create.content.contraptions.relays.elementary.BracketedTileEntityBehaviour;
|
2022-02-08 01:49:35 +01:00
|
|
|
import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
2022-05-31 21:51:38 +02:00
|
|
|
import com.simibubi.create.content.curiosities.deco.PlacardBlock;
|
2022-02-09 02:05:48 +01:00
|
|
|
import com.simibubi.create.content.logistics.block.chute.AbstractChuteBlock;
|
2022-02-16 03:14:31 +01:00
|
|
|
import com.simibubi.create.content.logistics.block.redstone.NixieTubeBlock;
|
Big Data
- Added the Display Board
- Added the Data Gatherer
- Nixie Tubes no longer animate text from "dynamic" vanilla text components
- Trains now keep travel time statistics for prediction purposes
- Created "Data-target" behaviour for Signs, Display Boards, Lecterns and Nixie Tubes
- Created "Data-source" behaviour for Train Stations, Clocks, Nixie Tubes, Content Observers, Stockpile Switches, Respawn Anchors, Depots, Belts, Belt Tunnels and Command Blocks
2022-04-05 19:04:04 +02:00
|
|
|
import com.simibubi.create.content.logistics.trains.management.display.FlapDisplayBlock;
|
2022-02-08 01:49:35 +01:00
|
|
|
import com.simibubi.create.content.logistics.trains.track.TrackBlock;
|
2022-02-09 21:13:33 +01:00
|
|
|
import com.simibubi.create.content.logistics.trains.track.TrackShape;
|
2022-02-09 02:05:48 +01:00
|
|
|
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
2022-02-08 01:49:35 +01:00
|
|
|
import com.simibubi.create.foundation.utility.Iterate;
|
2022-02-09 02:05:48 +01:00
|
|
|
import com.simibubi.create.foundation.utility.placement.IPlacementHelper;
|
|
|
|
import com.simibubi.create.foundation.utility.placement.PlacementHelpers;
|
2022-02-08 01:49:35 +01:00
|
|
|
|
|
|
|
import net.minecraft.core.BlockPos;
|
|
|
|
import net.minecraft.core.Direction;
|
|
|
|
import net.minecraft.core.Direction.Axis;
|
2022-07-03 16:34:35 +02:00
|
|
|
import net.minecraft.core.Direction.AxisDirection;
|
2022-02-09 21:13:33 +01:00
|
|
|
import net.minecraft.server.level.ServerLevel;
|
2022-02-09 02:05:48 +01:00
|
|
|
import net.minecraft.sounds.SoundEvents;
|
|
|
|
import net.minecraft.sounds.SoundSource;
|
|
|
|
import net.minecraft.world.InteractionHand;
|
|
|
|
import net.minecraft.world.InteractionResult;
|
|
|
|
import net.minecraft.world.entity.player.Player;
|
|
|
|
import net.minecraft.world.item.BlockItem;
|
|
|
|
import net.minecraft.world.item.ItemStack;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
2022-07-03 16:34:35 +02:00
|
|
|
import net.minecraft.world.item.context.UseOnContext;
|
2022-02-09 02:05:48 +01:00
|
|
|
import net.minecraft.world.level.BlockAndTintGetter;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.level.BlockGetter;
|
|
|
|
import net.minecraft.world.level.Level;
|
|
|
|
import net.minecraft.world.level.LevelAccessor;
|
|
|
|
import net.minecraft.world.level.block.Block;
|
2022-07-03 16:34:35 +02:00
|
|
|
import net.minecraft.world.level.block.ChainBlock;
|
|
|
|
import net.minecraft.world.level.block.LanternBlock;
|
2022-02-09 02:05:48 +01:00
|
|
|
import net.minecraft.world.level.block.Mirror;
|
|
|
|
import net.minecraft.world.level.block.Rotation;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.level.block.SimpleWaterloggedBlock;
|
|
|
|
import net.minecraft.world.level.block.WallBlock;
|
2022-02-09 02:05:48 +01:00
|
|
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
|
|
import net.minecraft.world.level.block.state.StateDefinition.Builder;
|
2022-07-03 16:34:35 +02:00
|
|
|
import net.minecraft.world.level.block.state.properties.AttachFace;
|
|
|
|
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.level.block.state.properties.BooleanProperty;
|
2022-07-03 16:34:35 +02:00
|
|
|
import net.minecraft.world.level.block.state.properties.EnumProperty;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.level.block.state.properties.Property;
|
|
|
|
import net.minecraft.world.level.material.FluidState;
|
|
|
|
import net.minecraft.world.level.material.Fluids;
|
|
|
|
import net.minecraft.world.level.pathfinder.PathComputationType;
|
2022-02-09 02:05:48 +01:00
|
|
|
import net.minecraft.world.phys.BlockHitResult;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.phys.shapes.CollisionContext;
|
2022-07-03 16:34:35 +02:00
|
|
|
import net.minecraft.world.phys.shapes.Shapes;
|
2022-02-08 01:49:35 +01:00
|
|
|
import net.minecraft.world.phys.shapes.VoxelShape;
|
|
|
|
|
|
|
|
public class GirderBlock extends Block implements SimpleWaterloggedBlock, IWrenchable {
|
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
private static final int placementHelperId = PlacementHelpers.register(new GirderPlacementHelper());
|
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
public static final BooleanProperty X = BooleanProperty.create("x");
|
|
|
|
public static final BooleanProperty Z = BooleanProperty.create("z");
|
|
|
|
public static final BooleanProperty TOP = BooleanProperty.create("top");
|
|
|
|
public static final BooleanProperty BOTTOM = BooleanProperty.create("bottom");
|
2022-07-03 16:34:35 +02:00
|
|
|
public static final EnumProperty<Axis> AXIS = BlockStateProperties.AXIS;
|
2022-02-08 01:49:35 +01:00
|
|
|
|
|
|
|
public GirderBlock(Properties p_49795_) {
|
|
|
|
super(p_49795_);
|
|
|
|
registerDefaultState(defaultBlockState().setValue(WATERLOGGED, false)
|
2022-07-03 16:34:35 +02:00
|
|
|
.setValue(AXIS, Axis.Y)
|
2022-02-08 01:49:35 +01:00
|
|
|
.setValue(TOP, false)
|
|
|
|
.setValue(BOTTOM, false)
|
|
|
|
.setValue(X, false)
|
|
|
|
.setValue(Z, false));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
protected void createBlockStateDefinition(Builder<Block, BlockState> pBuilder) {
|
2022-07-03 16:34:35 +02:00
|
|
|
super.createBlockStateDefinition(pBuilder.add(X, Z, TOP, BOTTOM, AXIS, WATERLOGGED));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@SuppressWarnings("deprecation")
|
|
|
|
public VoxelShape getBlockSupportShape(BlockState pState, BlockGetter pReader, BlockPos pPos) {
|
|
|
|
return Shapes.or(super.getBlockSupportShape(pState, pReader, pPos), AllShapes.EIGHT_VOXEL_POLE.get(Axis.Y));
|
2022-02-08 01:49:35 +01:00
|
|
|
}
|
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
@Override
|
|
|
|
public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand,
|
|
|
|
BlockHitResult pHit) {
|
|
|
|
if (pPlayer == null)
|
|
|
|
return InteractionResult.PASS;
|
|
|
|
|
|
|
|
ItemStack itemInHand = pPlayer.getItemInHand(pHand);
|
|
|
|
if (AllBlocks.SHAFT.isIn(itemInHand)) {
|
|
|
|
KineticTileEntity.switchToBlockState(pLevel, pPos, AllBlocks.METAL_GIRDER_ENCASED_SHAFT.getDefaultState()
|
|
|
|
.setValue(WATERLOGGED, pState.getValue(WATERLOGGED))
|
|
|
|
.setValue(TOP, pState.getValue(TOP))
|
|
|
|
.setValue(BOTTOM, pState.getValue(BOTTOM))
|
|
|
|
.setValue(GirderEncasedShaftBlock.HORIZONTAL_AXIS, pState.getValue(X) || pHit.getDirection()
|
|
|
|
.getAxis() == Axis.Z ? Axis.Z : Axis.X));
|
2022-07-03 16:34:35 +02:00
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
pLevel.playSound(null, pPos, SoundEvents.NETHERITE_BLOCK_HIT, SoundSource.BLOCKS, 0.5f, 1.25f);
|
|
|
|
if (!pLevel.isClientSide && !pPlayer.isCreative()) {
|
|
|
|
itemInHand.shrink(1);
|
|
|
|
if (itemInHand.isEmpty())
|
|
|
|
pPlayer.setItemInHand(pHand, ItemStack.EMPTY);
|
|
|
|
}
|
2022-07-03 16:34:35 +02:00
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
return InteractionResult.SUCCESS;
|
|
|
|
}
|
|
|
|
|
2022-06-04 01:54:19 +02:00
|
|
|
if (AllItems.WRENCH.isIn(itemInHand) && !pPlayer.isSteppingCarefully()) {
|
|
|
|
if (GirderWrenchBehavior.handleClick(pLevel, pPos, pState, pHit))
|
|
|
|
return InteractionResult.sidedSuccess(pLevel.isClientSide);
|
|
|
|
return InteractionResult.FAIL;
|
|
|
|
}
|
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
IPlacementHelper helper = PlacementHelpers.get(placementHelperId);
|
|
|
|
if (helper.matchesItem(itemInHand))
|
|
|
|
return helper.getOffset(pPlayer, pLevel, pState, pPos, pHit)
|
|
|
|
.placeInWorld(pLevel, (BlockItem) itemInHand.getItem(), pPlayer, pHand, pHit);
|
|
|
|
|
|
|
|
return InteractionResult.PASS;
|
|
|
|
}
|
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
@Override
|
|
|
|
public FluidState getFluidState(BlockState state) {
|
|
|
|
return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : Fluids.EMPTY.defaultFluidState();
|
|
|
|
}
|
|
|
|
|
2022-07-03 16:34:35 +02:00
|
|
|
@Override
|
|
|
|
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
|
|
|
|
return InteractionResult.PASS;
|
|
|
|
}
|
|
|
|
|
2022-02-09 21:13:33 +01:00
|
|
|
@Override
|
|
|
|
public void tick(BlockState p_60462_, ServerLevel p_60463_, BlockPos p_60464_, Random p_60465_) {
|
|
|
|
Block.updateOrDestroy(p_60462_, Block.updateFromNeighbourShapes(p_60462_, p_60463_, p_60464_), p_60463_,
|
|
|
|
p_60464_, 3);
|
|
|
|
}
|
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
@Override
|
|
|
|
public BlockState updateShape(BlockState state, Direction direction, BlockState neighbourState, LevelAccessor world,
|
|
|
|
BlockPos pos, BlockPos neighbourPos) {
|
|
|
|
if (state.getValue(WATERLOGGED))
|
|
|
|
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world));
|
|
|
|
Axis axis = direction.getAxis();
|
2022-07-03 16:34:35 +02:00
|
|
|
|
|
|
|
if (direction.getAxis() != Axis.Y) {
|
|
|
|
if (state.getValue(AXIS) != direction.getAxis()) {
|
|
|
|
Property<Boolean> updateProperty =
|
|
|
|
axis == Axis.X ? X : axis == Axis.Z ? Z : direction == Direction.UP ? TOP : BOTTOM;
|
|
|
|
if (!isConnected(world, pos, state, direction)
|
|
|
|
&& !isConnected(world, pos, state, direction.getOpposite()))
|
|
|
|
state = state.setValue(updateProperty, false);
|
|
|
|
}
|
|
|
|
} else if (state.getValue(AXIS) != Axis.Y) {
|
|
|
|
if (world.getBlockState(pos.above())
|
|
|
|
.getBlockSupportShape(world, pos.above())
|
|
|
|
.isEmpty())
|
|
|
|
state = state.setValue(TOP, false);
|
|
|
|
if (world.getBlockState(pos.below())
|
|
|
|
.getBlockSupportShape(world, pos.below())
|
|
|
|
.isEmpty())
|
|
|
|
state = state.setValue(BOTTOM, false);
|
|
|
|
}
|
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
for (Direction d : Iterate.directionsInAxis(axis))
|
|
|
|
state = updateState(world, pos, state, d);
|
2022-07-03 16:34:35 +02:00
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockState getStateForPlacement(BlockPlaceContext context) {
|
|
|
|
Level level = context.getLevel();
|
|
|
|
BlockPos pos = context.getClickedPos();
|
|
|
|
Direction face = context.getClickedFace();
|
|
|
|
FluidState ifluidstate = level.getFluidState(pos);
|
|
|
|
BlockState state = super.getStateForPlacement(context);
|
|
|
|
state = state.setValue(X, face.getAxis() == Axis.X);
|
|
|
|
state = state.setValue(Z, face.getAxis() == Axis.Z);
|
2022-07-03 16:34:35 +02:00
|
|
|
state = state.setValue(AXIS, face.getAxis());
|
2022-02-08 01:49:35 +01:00
|
|
|
|
|
|
|
for (Direction d : Iterate.directions)
|
|
|
|
state = updateState(level, pos, state, d);
|
|
|
|
|
|
|
|
return state.setValue(WATERLOGGED, Boolean.valueOf(ifluidstate.getType() == Fluids.WATER));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static BlockState updateState(LevelAccessor level, BlockPos pos, BlockState state, Direction d) {
|
|
|
|
Axis axis = d.getAxis();
|
|
|
|
Property<Boolean> updateProperty = axis == Axis.X ? X : axis == Axis.Z ? Z : d == Direction.UP ? TOP : BOTTOM;
|
|
|
|
BlockState sideState = level.getBlockState(pos.relative(d));
|
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
if (axis.isVertical())
|
|
|
|
return updateVerticalProperty(level, pos, state, updateProperty, sideState, d);
|
2022-02-08 01:49:35 +01:00
|
|
|
|
2022-07-03 16:34:35 +02:00
|
|
|
if (state.getValue(AXIS) == axis)
|
|
|
|
state = state.setValue(updateProperty, true);
|
|
|
|
else if (sideState.getBlock() instanceof GirderEncasedShaftBlock
|
2022-02-09 02:05:48 +01:00
|
|
|
&& sideState.getValue(GirderEncasedShaftBlock.HORIZONTAL_AXIS) != axis)
|
|
|
|
state = state.setValue(updateProperty, true);
|
2022-02-22 19:41:30 +01:00
|
|
|
else if (sideState.getBlock() == state.getBlock() && sideState.getValue(updateProperty))
|
2022-02-08 01:49:35 +01:00
|
|
|
state = state.setValue(updateProperty, true);
|
2022-02-22 19:41:30 +01:00
|
|
|
else if (sideState.getBlock() instanceof NixieTubeBlock && NixieTubeBlock.getFacing(sideState) == d)
|
|
|
|
state = state.setValue(updateProperty, true);
|
2022-05-31 21:51:38 +02:00
|
|
|
else if (sideState.getBlock() instanceof PlacardBlock && PlacardBlock.connectedDirection(sideState) == d)
|
|
|
|
state = state.setValue(updateProperty, true);
|
2022-02-22 19:41:30 +01:00
|
|
|
else if (isFacingBracket(level, pos, d))
|
2022-02-16 03:14:31 +01:00
|
|
|
state = state.setValue(updateProperty, true);
|
2022-02-08 01:49:35 +01:00
|
|
|
|
|
|
|
for (Direction d2 : Iterate.directionsInAxis(axis == Axis.X ? Axis.Z : Axis.X)) {
|
|
|
|
BlockState above = level.getBlockState(pos.above()
|
|
|
|
.relative(d2));
|
2023-05-09 18:23:47 +02:00
|
|
|
if (AllTags.AllBlockTags.GIRDABLE_TRACKS.matches(above)) {
|
2022-02-08 01:49:35 +01:00
|
|
|
TrackShape shape = above.getValue(TrackBlock.SHAPE);
|
|
|
|
if (shape == (axis == Axis.X ? TrackShape.XO : TrackShape.ZO))
|
|
|
|
state = state.setValue(updateProperty, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2022-02-22 19:41:30 +01:00
|
|
|
public static boolean isFacingBracket(BlockAndTintGetter level, BlockPos pos, Direction d) {
|
|
|
|
BlockEntity blockEntity = level.getBlockEntity(pos.relative(d));
|
|
|
|
if (!(blockEntity instanceof SmartTileEntity ste))
|
|
|
|
return false;
|
|
|
|
BracketedTileEntityBehaviour behaviour = ste.getBehaviour(BracketedTileEntityBehaviour.TYPE);
|
|
|
|
if (behaviour == null)
|
|
|
|
return false;
|
|
|
|
BlockState bracket = behaviour.getBracket();
|
2022-07-06 21:06:27 +02:00
|
|
|
if (bracket == null || !bracket.hasProperty(BracketBlock.FACING))
|
2022-02-22 19:41:30 +01:00
|
|
|
return false;
|
|
|
|
return bracket.getValue(BracketBlock.FACING) == d;
|
|
|
|
}
|
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
public static BlockState updateVerticalProperty(LevelAccessor level, BlockPos pos, BlockState state,
|
|
|
|
Property<Boolean> updateProperty, BlockState sideState, Direction d) {
|
2022-07-03 16:34:35 +02:00
|
|
|
boolean canAttach = false;
|
|
|
|
|
|
|
|
if (state.hasProperty(AXIS) && state.getValue(AXIS) == Axis.Y)
|
|
|
|
canAttach = true;
|
|
|
|
else if (isGirder(sideState) && isXGirder(sideState) == isZGirder(sideState))
|
|
|
|
canAttach = true;
|
2022-05-31 21:51:38 +02:00
|
|
|
else if (isGirder(sideState))
|
2022-07-03 16:34:35 +02:00
|
|
|
canAttach = true;
|
2022-02-09 02:05:48 +01:00
|
|
|
else if (sideState.hasProperty(WallBlock.UP) && sideState.getValue(WallBlock.UP))
|
2022-07-03 16:34:35 +02:00
|
|
|
canAttach = true;
|
2022-02-16 03:14:31 +01:00
|
|
|
else if (sideState.getBlock() instanceof NixieTubeBlock && NixieTubeBlock.getFacing(sideState) == d)
|
2022-07-03 16:34:35 +02:00
|
|
|
canAttach = true;
|
Big Data
- Added the Display Board
- Added the Data Gatherer
- Nixie Tubes no longer animate text from "dynamic" vanilla text components
- Trains now keep travel time statistics for prediction purposes
- Created "Data-target" behaviour for Signs, Display Boards, Lecterns and Nixie Tubes
- Created "Data-source" behaviour for Train Stations, Clocks, Nixie Tubes, Content Observers, Stockpile Switches, Respawn Anchors, Depots, Belts, Belt Tunnels and Command Blocks
2022-04-05 19:04:04 +02:00
|
|
|
else if (sideState.getBlock() instanceof FlapDisplayBlock)
|
2022-07-03 16:34:35 +02:00
|
|
|
canAttach = true;
|
|
|
|
else if (sideState.getBlock() instanceof LanternBlock
|
|
|
|
&& (d == Direction.DOWN) == (sideState.getValue(LanternBlock.HANGING)))
|
|
|
|
canAttach = true;
|
|
|
|
else if (sideState.getBlock() instanceof ChainBlock && sideState.getValue(ChainBlock.AXIS) == Axis.Y)
|
|
|
|
canAttach = true;
|
|
|
|
else if (sideState.hasProperty(FACE)) {
|
|
|
|
if (sideState.getValue(FACE) == AttachFace.CEILING && d == Direction.DOWN)
|
|
|
|
canAttach = true;
|
|
|
|
else if (sideState.getValue(FACE) == AttachFace.FLOOR && d == Direction.UP)
|
|
|
|
canAttach = true;
|
|
|
|
} else if (sideState.getBlock() instanceof PlacardBlock && PlacardBlock.connectedDirection(sideState) == d)
|
|
|
|
canAttach = true;
|
2022-02-22 19:41:30 +01:00
|
|
|
else if (isFacingBracket(level, pos, d))
|
2022-07-03 16:34:35 +02:00
|
|
|
canAttach = true;
|
|
|
|
|
|
|
|
if (canAttach)
|
|
|
|
return state.setValue(updateProperty, true);
|
2022-02-09 02:05:48 +01:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2022-02-22 19:41:30 +01:00
|
|
|
public static boolean isGirder(BlockState state) {
|
|
|
|
return state.getBlock() instanceof GirderBlock || state.getBlock() instanceof GirderEncasedShaftBlock;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isXGirder(BlockState state) {
|
|
|
|
return (state.getBlock() instanceof GirderBlock && state.getValue(X))
|
|
|
|
|| (state.getBlock() instanceof GirderEncasedShaftBlock
|
|
|
|
&& state.getValue(GirderEncasedShaftBlock.HORIZONTAL_AXIS) == Axis.Z);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isZGirder(BlockState state) {
|
|
|
|
return (state.getBlock() instanceof GirderBlock && state.getValue(Z))
|
|
|
|
|| (state.getBlock() instanceof GirderEncasedShaftBlock
|
|
|
|
&& state.getValue(GirderEncasedShaftBlock.HORIZONTAL_AXIS) == Axis.X);
|
|
|
|
}
|
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
@Override
|
|
|
|
public VoxelShape getShape(BlockState state, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
|
|
|
|
boolean x = state.getValue(GirderBlock.X);
|
|
|
|
boolean z = state.getValue(GirderBlock.Z);
|
|
|
|
return x ? z ? AllShapes.GIRDER_CROSS : AllShapes.GIRDER_BEAM.get(Axis.X)
|
|
|
|
: z ? AllShapes.GIRDER_BEAM.get(Axis.Z) : AllShapes.EIGHT_VOXEL_POLE.get(Axis.Y);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isPathfindable(BlockState state, BlockGetter reader, BlockPos pos, PathComputationType type) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-02-09 02:05:48 +01:00
|
|
|
public static boolean isConnected(BlockAndTintGetter world, BlockPos pos, BlockState state, Direction side) {
|
|
|
|
Axis axis = side.getAxis();
|
|
|
|
if (state.getBlock() instanceof GirderBlock && !state.getValue(axis == Axis.X ? X : Z))
|
|
|
|
return false;
|
|
|
|
if (state.getBlock() instanceof GirderEncasedShaftBlock
|
2022-02-22 19:41:30 +01:00
|
|
|
&& state.getValue(GirderEncasedShaftBlock.HORIZONTAL_AXIS) == axis)
|
2022-02-09 02:05:48 +01:00
|
|
|
return false;
|
|
|
|
BlockPos relative = pos.relative(side);
|
|
|
|
BlockState blockState = world.getBlockState(relative);
|
|
|
|
if (blockState.isAir())
|
|
|
|
return false;
|
2022-02-16 03:14:31 +01:00
|
|
|
if (blockState.getBlock() instanceof NixieTubeBlock && NixieTubeBlock.getFacing(blockState) == side)
|
|
|
|
return true;
|
2022-02-22 19:41:30 +01:00
|
|
|
if (isFacingBracket(world, pos, side))
|
|
|
|
return true;
|
2022-05-31 21:51:38 +02:00
|
|
|
if (blockState.getBlock() instanceof PlacardBlock && PlacardBlock.connectedDirection(blockState) == side)
|
|
|
|
return true;
|
2022-02-09 02:05:48 +01:00
|
|
|
VoxelShape shape = blockState.getShape(world, relative);
|
|
|
|
if (shape.isEmpty())
|
|
|
|
return false;
|
|
|
|
if (Block.isFaceFull(shape, side.getOpposite()) && blockState.getMaterial()
|
|
|
|
.isSolidBlocking())
|
|
|
|
return true;
|
|
|
|
return AbstractChuteBlock.getChuteFacing(blockState) == Direction.DOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockState rotate(BlockState state, Rotation rot) {
|
2022-07-03 16:34:35 +02:00
|
|
|
state = state.setValue(AXIS,
|
|
|
|
rot.rotate(Direction.fromAxisAndDirection(state.getValue(AXIS), AxisDirection.POSITIVE))
|
|
|
|
.getAxis());
|
2022-02-09 02:05:48 +01:00
|
|
|
if (rot.rotate(Direction.EAST)
|
|
|
|
.getAxis() == Axis.X)
|
|
|
|
return state;
|
|
|
|
return state.setValue(X, state.getValue(Z))
|
|
|
|
.setValue(Z, state.getValue(Z));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public BlockState mirror(BlockState state, Mirror mirrorIn) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2022-02-08 01:49:35 +01:00
|
|
|
}
|