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)
.initialProperties(Material.NETHER_WOOD) // for villager AI..
.properties(p -> p.color(MaterialColor.TERRACOTTA_CYAN))
.properties(p -> p.sound(SoundType.NETHERITE_BLOCK))
.properties(p -> p.color(MaterialColor.TERRACOTTA_CYAN)
.sound(SoundType.NETHERITE_BLOCK)
.requiresCorrectToolForDrops()
.strength(3.0F, 6.0F))
.blockstate((c, p) -> {
ModelFile bottom = AssetLookup.partialBaseModel(c, p, "bottom");
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);
BlockState beltBlock = AllBlocks.BELT.getDefaultState();
boolean failed = false;
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;
BlockState shaftState = world.getBlockState(pos);
boolean pulley = ShaftBlock.isShaft(shaftState);
@ -147,6 +158,13 @@ public class BeltConnectorItem extends BlockItem {
.setValue(BeltBlock.PART, part)
.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) {

View file

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

View file

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

View file

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

View file

@ -68,7 +68,7 @@ public abstract class LaunchedItem {
public static LaunchedItem fromNBT(CompoundTag c) {
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);
return launched;
}
@ -152,10 +152,14 @@ public abstract class LaunchedItem {
boolean isStart = state.getValue(BeltBlock.PART) == BeltPart.START;
BlockPos offset = BeltBlock.nextSegmentPosition(state, BlockPos.ZERO, isStart);
int i = length - 1;
Axis axis = state.getValue(BeltBlock.SLOPE) == BeltSlope.SIDEWAYS ? Axis.Y : state.getValue(BeltBlock.HORIZONTAL_FACING).getClockWise().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));
Axis axis = state.getValue(BeltBlock.SLOPE) == BeltSlope.SIDEWAYS ? Axis.Y
: state.getValue(BeltBlock.HORIZONTAL_FACING)
.getClockWise()
.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));
}
}