Skip to content

Commit b91757a

Browse files
committed
Cold nights
- Fix nixie tubes and redstone links being powered by torches supporting them #8734 - Fix precision issue in TrackNodeLocation #9509 - Fix Item requirement for placard's being completely broken #9511
1 parent 6409450 commit b91757a

File tree

5 files changed

+39
-40
lines changed

5 files changed

+39
-40
lines changed

src/main/java/com/simibubi/create/compat/computercraft/implementation/peripherals/NixieTubePeripheral.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected void onLastDetach() {
5454
NixieTubeBlock.walkNixies(world, blockEntity.getBlockPos(), false,
5555
(currentPos, rowPosition) -> {
5656
if (world.getBlockEntity(currentPos) instanceof NixieTubeBlockEntity ntbe) {
57-
NixieTubeBlock.updateDisplayedRedstoneValue(ntbe, true);
57+
NixieTubeBlock.updateDisplayedRedstoneValue(ntbe, state, true);
5858
}
5959
});
6060
}

src/main/java/com/simibubi/create/content/redstone/link/RedstoneLinkBlock.java

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState
8585
IBE.onRemove(pState, pLevel, pPos, pNewState);
8686
}
8787

88-
public void updateTransmittedSignal(BlockState state, Level worldIn, BlockPos pos) {
89-
if (worldIn.isClientSide)
88+
public void updateTransmittedSignal(BlockState state, Level level, BlockPos pos) {
89+
if (level.isClientSide)
9090
return;
9191
if (state.getValue(RECEIVER))
9292
return;
9393

94-
int power = getPower(worldIn, pos);
95-
int powerFromPanels = getBlockEntityOptional(worldIn, pos).map(be -> {
94+
int power = getPower(level, state, pos);
95+
int powerFromPanels = getBlockEntityOptional(level, pos).map(be -> {
9696
if (be.panelSupport == null)
9797
return 0;
9898
Boolean tri = be.panelSupport.shouldBePoweredTristate();
@@ -110,18 +110,20 @@ public void updateTransmittedSignal(BlockState state, Level worldIn, BlockPos po
110110

111111
boolean previouslyPowered = state.getValue(POWERED);
112112
if (previouslyPowered != power > 0)
113-
worldIn.setBlock(pos, state.cycle(POWERED), Block.UPDATE_CLIENTS);
113+
level.setBlock(pos, state.cycle(POWERED), Block.UPDATE_CLIENTS);
114114

115115
int transmit = power;
116-
withBlockEntityDo(worldIn, pos, be -> be.transmit(transmit));
116+
withBlockEntityDo(level, pos, be -> be.transmit(transmit));
117117
}
118118

119-
private int getPower(Level worldIn, BlockPos pos) {
119+
private static int getPower(Level level, BlockState state, BlockPos pos) {
120120
int power = 0;
121121
for (Direction direction : Iterate.directions)
122-
power = Math.max(worldIn.getSignal(pos.relative(direction), direction), power);
123-
for (Direction direction : Iterate.directions)
124-
power = Math.max(worldIn.getSignal(pos.relative(direction), Direction.UP), power);
122+
power = Math.max(level.getSignal(pos.relative(direction), direction), power);
123+
for (Direction direction : Iterate.directions) {
124+
if (state.getValue(FACING).getOpposite() != direction)
125+
power = Math.max(level.getSignal(pos.relative(direction), Direction.UP), power);
126+
}
125127
return power;
126128
}
127129

@@ -160,16 +162,16 @@ protected InteractionResult useWithoutItem(BlockState state, Level level, BlockP
160162
return InteractionResult.PASS;
161163
}
162164

163-
public InteractionResult toggleMode(BlockState state, Level worldIn, BlockPos pos) {
164-
if (worldIn.isClientSide)
165+
public InteractionResult toggleMode(BlockState state, Level level, BlockPos pos) {
166+
if (level.isClientSide)
165167
return InteractionResult.SUCCESS;
166168

167-
return onBlockEntityUse(worldIn, pos, be -> {
169+
return onBlockEntityUse(level, pos, be -> {
168170
Boolean wasReceiver = state.getValue(RECEIVER);
169-
boolean blockPowered = worldIn.hasNeighborSignal(pos);
170-
worldIn.setBlock(pos, state.cycle(RECEIVER)
171+
boolean blockPowered = level.hasNeighborSignal(pos);
172+
level.setBlock(pos, state.cycle(RECEIVER)
171173
.setValue(POWERED, blockPowered), Block.UPDATE_ALL);
172-
be.transmit(wasReceiver ? 0 : getPower(worldIn, pos));
174+
be.transmit(wasReceiver ? 0 : getPower(level, state, pos));
173175
return InteractionResult.SUCCESS;
174176
});
175177
}

src/main/java/com/simibubi/create/content/redstone/nixieTube/NixieTubeBlock.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ public void onRemove(BlockState state, Level world, BlockPos pos, BlockState new
232232
} :
233233
(currentPos, rowPosition) -> {
234234
if (world.getBlockEntity(currentPos) instanceof NixieTubeBlockEntity ntbe)
235-
NixieTubeBlock.updateDisplayedRedstoneValue(ntbe, true);
235+
NixieTubeBlock.updateDisplayedRedstoneValue(ntbe, state, true);
236236
});
237237
}
238238
Direction right = left.getOpposite();
@@ -246,7 +246,7 @@ public void onRemove(BlockState state, Level world, BlockPos pos, BlockState new
246246
} :
247247
(currentPos, rowPosition) -> {
248248
if (world.getBlockEntity(currentPos) instanceof NixieTubeBlockEntity ntbe)
249-
NixieTubeBlock.updateDisplayedRedstoneValue(ntbe, true);
249+
NixieTubeBlock.updateDisplayedRedstoneValue(ntbe, state, true);
250250
});
251251
}
252252
}
@@ -266,16 +266,11 @@ public ItemRequirement getRequiredItems(BlockState state, BlockEntity be) {
266266
@Override
267267
public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
268268
Direction facing = pState.getValue(FACING);
269-
switch (pState.getValue(FACE)) {
270-
case CEILING:
271-
return AllShapes.NIXIE_TUBE_CEILING.get(facing.getClockWise()
272-
.getAxis());
273-
case FLOOR:
274-
return AllShapes.NIXIE_TUBE.get(facing.getClockWise()
275-
.getAxis());
276-
default:
277-
return AllShapes.NIXIE_TUBE_WALL.get(facing);
278-
}
269+
return switch (pState.getValue(FACE)) {
270+
case CEILING -> AllShapes.NIXIE_TUBE_CEILING.get(facing.getClockWise().getAxis());
271+
case FLOOR -> AllShapes.NIXIE_TUBE.get(facing.getClockWise().getAxis());
272+
default -> AllShapes.NIXIE_TUBE_WALL.get(facing);
273+
};
279274
}
280275

281276
@Override
@@ -343,17 +338,17 @@ public void onPlace(BlockState state, Level worldIn, BlockPos pos, BlockState ol
343338
updateDisplayedRedstoneValue(state, worldIn, pos);
344339
}
345340

346-
public static void updateDisplayedRedstoneValue(NixieTubeBlockEntity be, boolean force) {
341+
public static void updateDisplayedRedstoneValue(NixieTubeBlockEntity be, BlockState state, boolean force) {
347342
if (be.getLevel() == null || be.getLevel().isClientSide)
348343
return;
349344
if (be.reactsToRedstone() || force)
350-
be.updateRedstoneStrength(getPower(be.getLevel(), be.getBlockPos()));
345+
be.updateRedstoneStrength(getPower(be.getLevel(), state, be.getBlockPos()));
351346
}
352347

353-
private void updateDisplayedRedstoneValue(BlockState state, Level worldIn, BlockPos pos) {
354-
if (worldIn.isClientSide)
348+
private void updateDisplayedRedstoneValue(BlockState state, Level level, BlockPos pos) {
349+
if (level.isClientSide)
355350
return;
356-
withBlockEntityDo(worldIn, pos, be -> NixieTubeBlock.updateDisplayedRedstoneValue(be, false));
351+
withBlockEntityDo(level, pos, be -> NixieTubeBlock.updateDisplayedRedstoneValue(be, state, false));
357352
}
358353

359354
static boolean isValidBlock(BlockGetter world, BlockPos pos, boolean above) {
@@ -362,12 +357,14 @@ static boolean isValidBlock(BlockGetter world, BlockPos pos, boolean above) {
362357
.isEmpty();
363358
}
364359

365-
private static int getPower(Level worldIn, BlockPos pos) {
360+
private static int getPower(Level level, BlockState state, BlockPos pos) {
366361
int power = 0;
367362
for (Direction direction : Iterate.directions)
368-
power = Math.max(worldIn.getSignal(pos.relative(direction), direction), power);
369-
for (Direction direction : Iterate.directions)
370-
power = Math.max(worldIn.getSignal(pos.relative(direction), Direction.UP), power);
363+
power = Math.max(level.getSignal(pos.relative(direction), direction), power);
364+
for (Direction direction : Iterate.directions) {
365+
if (state.getValue(FACING).getOpposite() != direction)
366+
power = Math.max(level.getSignal(pos.relative(direction), Direction.UP), power);
367+
}
371368
return power;
372369
}
373370

src/main/java/com/simibubi/create/content/schematics/SchematicPrinter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public ItemRequirement getCurrentRequirement() {
253253
BlockEntity blockEntity = null;
254254
if (blockState.hasBlockEntity()) {
255255
blockEntity = ((EntityBlock) blockState.getBlock()).newBlockEntity(target, blockState);
256-
CompoundTag data = BlockHelper.prepareBlockEntityData(blockReader, blockState, blockEntity);
256+
CompoundTag data = BlockHelper.prepareBlockEntityData(blockReader, blockState, blockReader.getBlockEntity(target));
257257
if (blockEntity != null && data != null)
258258
blockEntity.loadWithComponents(data, blockReader.registryAccess());
259259
}

src/main/java/com/simibubi/create/content/trains/graph/TrackNodeLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public TrackNodeLocation(Vec3 vec) {
3030
}
3131

3232
public TrackNodeLocation(double x, double y, double z) {
33-
super(Mth.floor(Math.round(x * 2)), Mth.floor(y) * 2, Mth.floor(Math.round(z * 2)));
33+
super(Mth.floor((double) Math.round(x * 2)), Mth.floor(y) * 2, Mth.floor((double) Math.round(z * 2)));
3434
}
3535

3636
public TrackNodeLocation in(Level level) {

0 commit comments

Comments
 (0)