From 648f43e8709b207163c0f88ce7d6468b4719e0be Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sat, 4 Jun 2022 00:22:13 +0200 Subject: [PATCH] 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 --- .../java/com/simibubi/create/AllBlocks.java | 6 ++++-- .../relays/belt/item/BeltConnectorItem.java | 18 ++++++++++++++++++ .../content/curiosities/deco/PlacardBlock.java | 2 +- .../source/StationSummaryDisplaySource.java | 11 +++++++++-- .../trains/entity/CarriageSounds.java | 12 ++++++------ .../content/schematics/block/LaunchedItem.java | 14 +++++++++----- 6 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 0e46e8e03..3088dd535 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -1558,8 +1558,10 @@ public class AllBlocks { public static final BlockEntry 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"); diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java index 03d894716..1b8941898 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/item/BeltConnectorItem.java @@ -134,8 +134,19 @@ public class BeltConnectorItem extends BlockItem { List 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) { diff --git a/src/main/java/com/simibubi/create/content/curiosities/deco/PlacardBlock.java b/src/main/java/com/simibubi/create/content/curiosities/deco/PlacardBlock.java index b82cb1a1b..cecdd7bd7 100644 --- a/src/main/java/com/simibubi/create/content/curiosities/deco/PlacardBlock.java +++ b/src/main/java/com/simibubi/create/content/curiosities/deco/PlacardBlock.java @@ -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; } diff --git a/src/main/java/com/simibubi/create/content/logistics/block/display/source/StationSummaryDisplaySource.java b/src/main/java/com/simibubi/create/content/logistics/block/display/source/StationSummaryDisplaySource.java index e53496982..44a27d762 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/display/source/StationSummaryDisplaySource.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/display/source/StationSummaryDisplaySource.java @@ -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(""); diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java index b3d0431ca..4c072d045 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageSounds.java @@ -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; diff --git a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java index 391980395..3990f5794 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/LaunchedItem.java @@ -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)); } }