Skip to content

Commit

Permalink
#fix: 完成传送带上下行方向放置
Browse files Browse the repository at this point in the history
  • Loading branch information
HeChuQIU committed May 20, 2024
1 parent cf1da89 commit 08a2856
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockSt
super.createBlockStateDefinition(builder);
}

public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
public @NotNull VoxelShape getShape(BlockState pState, @NotNull BlockGetter pLevel, @NotNull BlockPos pPos, @NotNull CollisionContext pContext) {
return switch (pState.getValue(SHAPE)) {
case DESCENDING_EAST, DESCENDING_NORTH, DESCENDING_SOUTH, DESCENDING_WEST, ASCENDING_EAST, ASCENDING_NORTH,
ASCENDING_SOUTH, ASCENDING_WEST -> HALF_BLOCK_AABB;
Expand Down Expand Up @@ -87,7 +87,7 @@ protected BlockState updateDir(Level level, BlockPos pos, BlockState state, bool
}
}

public void neighborChanged(BlockState pState, Level pLevel, BlockPos pPos, Block pBlock, BlockPos pFromPos, boolean pIsMoving) {
public void neighborChanged(@NotNull BlockState pState, Level pLevel, @NotNull BlockPos pPos, @NotNull Block pBlock, @NotNull BlockPos pFromPos, boolean pIsMoving) {
if (!pLevel.isClientSide && pLevel.getBlockState(pPos).is(this)) {
var shape = pState.getValue(SHAPE);
if (shouldBeRemoved(pPos, pLevel, shape)) {
Expand Down Expand Up @@ -119,7 +119,7 @@ private static boolean shouldBeRemoved(BlockPos pPos, Level pLevel, ConveyorShap
// }
}

public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) {
public void onRemove(@NotNull BlockState pState, @NotNull Level pLevel, @NotNull BlockPos pPos, @NotNull BlockState pNewState, boolean pIsMoving) {
if (!pIsMoving) {
super.onRemove(pState, pLevel, pPos, pNewState, pIsMoving);
// if (pState.getValue(SHAPE).isAscending()) {
Expand All @@ -140,16 +140,16 @@ public BlockState getStateForPlacement(BlockPlaceContext context) {
}

private static @NotNull ConveyorShape getConveyorShape(Level level, Direction outputDirection, BlockPos pos) {
BlockPos outputPos = pos.relative(Direction.UP);
BlockPos outputPos = pos.relative(outputDirection);
ConveyorShape shape;
boolean output = Stream.of(level.getBlockState(outputPos))
.filter(s -> s.getValues().containsKey(SHAPE))
.flatMap(s -> Arrays.stream(s.getValue(SHAPE).getInputBlockPos(outputPos)))
.anyMatch(pos::equals);
boolean outputUp = Stream.of(level.getBlockState(outputPos.above()))
.filter(s -> s.getValues().containsKey(SHAPE))
.map(s -> Arrays.stream(s.getValue(SHAPE).getInputBlockPos(outputPos.above())))
.anyMatch(pos.above()::equals);
.map(s -> s.getValue(SHAPE).getOutputBlockPos(outputPos.above()))
.anyMatch(p -> !pos.above().equals(p));
if (!output && outputUp) {
shape = switch (outputDirection) {
case NORTH -> ConveyorShape.ASCENDING_NORTH;
Expand Down Expand Up @@ -283,7 +283,7 @@ else if (inputDirections.contains(Direction.WEST))

@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
public BlockEntity newBlockEntity(@NotNull BlockPos pPos, @NotNull BlockState pState) {
return new ConveyorBlockEntity(pPos, pState);
}

Expand All @@ -296,7 +296,7 @@ public BlockEntity newBlockEntity(BlockPos pPos, BlockState pState) {
* whenever possible. Implementing/overriding is fine.
*/
@Override
public RenderShape getRenderShape(@NotNull BlockState state) {
public @NotNull RenderShape getRenderShape(@NotNull BlockState state) {
return RenderShape.MODEL;
}
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/mindustry/blockstates/conveyor.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@
},
"shape=ascending_north": {
"model": "mindustry:block/conveyor_5",
"y": 90
"y": 270
},
"shape=ascending_west": {
"model": "mindustry:block/conveyor_5",
"y": 180
},
"shape=ascending_south": {
"model": "mindustry:block/conveyor_5",
"y": 270
"y": 90
},
"shape=descending_west": {
"model": "mindustry:block/conveyor_5_m"
Expand Down

0 comments on commit 08a2856

Please sign in to comment.