Fridays' one-liners

- Fixed NPE with train sounds
- Belts launched by a schematicannon can no longer replace bedrock
- Placards now unpower one game tick sooner
- Fixed station display link not assigning default values correctly
- Fixed Train doors able to be destroyed in a single punch
This commit is contained in:
simibubi 2022-06-04 00:22:13 +02:00
parent a684c9956c
commit 648f43e870
6 changed files with 47 additions and 16 deletions

View file

@ -1558,8 +1558,10 @@ public class AllBlocks {
public static final BlockEntry<TrainDoorBlock> TRAIN_DOOR = REGISTRATE.block("train_door", TrainDoorBlock::new) public static final BlockEntry<TrainDoorBlock> TRAIN_DOOR = REGISTRATE.block("train_door", TrainDoorBlock::new)
.initialProperties(Material.NETHER_WOOD) // for villager AI.. .initialProperties(Material.NETHER_WOOD) // for villager AI..
.properties(p -> p.color(MaterialColor.TERRACOTTA_CYAN)) .properties(p -> p.color(MaterialColor.TERRACOTTA_CYAN)
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK)) .sound(SoundType.NETHERITE_BLOCK)
.requiresCorrectToolForDrops()
.strength(3.0F, 6.0F))
.blockstate((c, p) -> { .blockstate((c, p) -> {
ModelFile bottom = AssetLookup.partialBaseModel(c, p, "bottom"); ModelFile bottom = AssetLookup.partialBaseModel(c, p, "bottom");
ModelFile top = AssetLookup.partialBaseModel(c, p, "top"); ModelFile top = AssetLookup.partialBaseModel(c, p, "top");

View file

@ -134,8 +134,19 @@ public class BeltConnectorItem extends BlockItem {
List<BlockPos> beltsToCreate = getBeltChainBetween(start, end, slope, facing); List<BlockPos> beltsToCreate = getBeltChainBetween(start, end, slope, facing);
BlockState beltBlock = AllBlocks.BELT.getDefaultState(); BlockState beltBlock = AllBlocks.BELT.getDefaultState();
boolean failed = false;
for (BlockPos pos : beltsToCreate) { for (BlockPos pos : beltsToCreate) {
BlockState existingBlock = world.getBlockState(pos);
if (existingBlock.getDestroySpeed(world, pos) == -1) {
failed = true;
break;
}
if (!existingBlock.getMaterial()
.isReplaceable())
world.destroyBlock(pos, false);
BeltPart part = pos.equals(start) ? BeltPart.START : pos.equals(end) ? BeltPart.END : BeltPart.MIDDLE; BeltPart part = pos.equals(start) ? BeltPart.START : pos.equals(end) ? BeltPart.END : BeltPart.MIDDLE;
BlockState shaftState = world.getBlockState(pos); BlockState shaftState = world.getBlockState(pos);
boolean pulley = ShaftBlock.isShaft(shaftState); boolean pulley = ShaftBlock.isShaft(shaftState);
@ -147,6 +158,13 @@ public class BeltConnectorItem extends BlockItem {
.setValue(BeltBlock.PART, part) .setValue(BeltBlock.PART, part)
.setValue(BeltBlock.HORIZONTAL_FACING, facing)); .setValue(BeltBlock.HORIZONTAL_FACING, facing));
} }
if (!failed)
return;
for (BlockPos pos : beltsToCreate)
if (AllBlocks.BELT.has(world.getBlockState(pos)))
world.destroyBlock(pos, false);
} }
private static Direction getFacingFromTo(BlockPos start, BlockPos end) { private static Direction getFacingFromTo(BlockPos start, BlockPos end) {

View file

@ -142,7 +142,7 @@ public class PlacardBlock extends FaceAttachedHorizontalDirectionalBlock
AllSoundEvents.CONFIRM.play(pLevel, null, pPos, 1, 1); AllSoundEvents.CONFIRM.play(pLevel, null, pPos, 1, 1);
pLevel.setBlock(pPos, pState.setValue(POWERED, true), 3); pLevel.setBlock(pPos, pState.setValue(POWERED, true), 3);
updateNeighbours(pState, pLevel, pPos); updateNeighbours(pState, pLevel, pPos);
pte.poweredTicks = 20; pte.poweredTicks = 19;
pte.notifyUpdate(); pte.notifyUpdate();
return InteractionResult.SUCCESS; return InteractionResult.SUCCESS;
} }

View file

@ -159,9 +159,15 @@ public class StationSummaryDisplaySource extends DisplaySource {
@Override @Override
public void populateData(DisplayLinkContext context) { public void populateData(DisplayLinkContext context) {
CompoundTag conf = context.sourceConfig(); CompoundTag conf = context.sourceConfig();
if (!conf.contains("PlatformColumn"))
conf.putInt("PlatformColumn", 3);
if (!conf.contains("NameColumn"))
conf.putInt("NameColumn", 50);
if (conf.contains("Filter")) if (conf.contains("Filter"))
return; return;
if (!(context.getSourceTE()instanceof StationTileEntity stationTe)) if (!(context.getSourceTE() instanceof StationTileEntity stationTe))
return; return;
GlobalStation station = stationTe.getStation(); GlobalStation station = stationTe.getStation();
if (station == null) if (station == null)
@ -171,7 +177,8 @@ public class StationSummaryDisplaySource extends DisplaySource {
@Override @Override
@OnlyIn(Dist.CLIENT) @OnlyIn(Dist.CLIENT)
public void initConfigurationWidgets(DisplayLinkContext context, ModularGuiLineBuilder builder, boolean isFirstLine) { public void initConfigurationWidgets(DisplayLinkContext context, ModularGuiLineBuilder builder,
boolean isFirstLine) {
if (isFirstLine) { if (isFirstLine) {
builder.addTextInput(0, 137, (e, t) -> { builder.addTextInput(0, 137, (e, t) -> {
e.setValue(""); e.setValue("");

View file

@ -95,8 +95,8 @@ public class CarriageSounds {
if (entity.carriageIndex == 0) { if (entity.carriageIndex == 0) {
float v = volume * (1 - seatCrossfade.getValue() * .35f) * .75f; float v = volume * (1 - seatCrossfade.getValue() * .35f) * .75f;
if ((3 + tick) % 4 == 0) if ((3 + tick) % 4 == 0)
AllSoundEvents.STEAM.playAt(entity.level, soundLocation, v * ((tick + 7) % 8 == 0 ? 0.75f : .45f), 1.17f, AllSoundEvents.STEAM.playAt(entity.level, soundLocation, v * ((tick + 7) % 8 == 0 ? 0.75f : .45f),
false); 1.17f, false);
if (tick % 16 == 0) if (tick % 16 == 0)
AllSoundEvents.STEAM.playAt(entity.level, soundLocation, v * 1.5f, .8f, false); AllSoundEvents.STEAM.playAt(entity.level, soundLocation, v * 1.5f, .8f, false);
} }
@ -155,10 +155,10 @@ public class CarriageSounds {
} }
public void submitSharedSoundVolume(Vec3 location, float volume) { public void submitSharedSoundVolume(Vec3 location, float volume) {
sharedWheelSound = Minecraft mc = Minecraft.getInstance();
playIfMissing(Minecraft.getInstance(), sharedWheelSound, AllSoundEvents.TRAIN2.getMainEvent()); minecartEsqueSound = playIfMissing(mc, minecartEsqueSound, AllSoundEvents.TRAIN.getMainEvent());
sharedWheelSoundSeated = sharedWheelSound = playIfMissing(mc, sharedWheelSound, AllSoundEvents.TRAIN2.getMainEvent());
playIfMissing(Minecraft.getInstance(), sharedWheelSoundSeated, AllSoundEvents.TRAIN3.getMainEvent()); sharedWheelSoundSeated = playIfMissing(mc, sharedWheelSoundSeated, AllSoundEvents.TRAIN3.getMainEvent());
boolean approach = true; boolean approach = true;

View file

@ -68,7 +68,7 @@ public abstract class LaunchedItem {
public static LaunchedItem fromNBT(CompoundTag c) { public static LaunchedItem fromNBT(CompoundTag c) {
LaunchedItem launched = c.contains("Length") ? new LaunchedItem.ForBelt() LaunchedItem launched = c.contains("Length") ? new LaunchedItem.ForBelt()
: c.contains("BlockState") ? new LaunchedItem.ForBlockState() : new LaunchedItem.ForEntity(); : c.contains("BlockState") ? new LaunchedItem.ForBlockState() : new LaunchedItem.ForEntity();
launched.readNBT(c); launched.readNBT(c);
return launched; return launched;
} }
@ -152,10 +152,14 @@ public abstract class LaunchedItem {
boolean isStart = state.getValue(BeltBlock.PART) == BeltPart.START; boolean isStart = state.getValue(BeltBlock.PART) == BeltPart.START;
BlockPos offset = BeltBlock.nextSegmentPosition(state, BlockPos.ZERO, isStart); BlockPos offset = BeltBlock.nextSegmentPosition(state, BlockPos.ZERO, isStart);
int i = length - 1; int i = length - 1;
Axis axis = state.getValue(BeltBlock.SLOPE) == BeltSlope.SIDEWAYS ? Axis.Y : state.getValue(BeltBlock.HORIZONTAL_FACING).getClockWise().getAxis(); Axis axis = state.getValue(BeltBlock.SLOPE) == BeltSlope.SIDEWAYS ? Axis.Y
world.setBlockAndUpdate(target, AllBlocks.SHAFT.getDefaultState().setValue(AbstractSimpleShaftBlock.AXIS, axis)); : state.getValue(BeltBlock.HORIZONTAL_FACING)
BeltConnectorItem .getClockWise()
.createBelts(world, target, target.offset(offset.getX() * i, offset.getY() * i, offset.getZ() * i)); .getAxis();
world.setBlockAndUpdate(target, AllBlocks.SHAFT.getDefaultState()
.setValue(AbstractSimpleShaftBlock.AXIS, axis));
BeltConnectorItem.createBelts(world, target,
target.offset(offset.getX() * i, offset.getY() * i, offset.getZ() * i));
} }
} }