The pain chain

- Fixed chain conveyor chains getting culled while in view
- Chain conveyor riding now updates the player visual instantly after dismount
- Fixed chain conveyor riding animation stopping when too far from the controlling block
- Added sounds for stock keeper and ticker ui
This commit is contained in:
simibubi 2025-01-06 11:18:08 +01:00
parent e86fd31a7b
commit dda7855aa9
10 changed files with 104 additions and 23 deletions

View file

@ -10,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.Create;
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlock;
import com.simibubi.create.content.decoration.steamWhistle.WhistleBlockEntity;
import com.simibubi.create.content.kinetics.BlockStressValues;
@ -88,12 +87,13 @@ public class BoilerData {
public void tick(FluidTankBlockEntity controller) {
if (!isActive())
return;
if (controller.getLevel().isClientSide) {
pools.values().forEach(p -> p.play(controller.getLevel()));
Level level = controller.getLevel();
if (level.isClientSide) {
pools.values().forEach(p -> p.play(level));
gauge.tickChaser();
float current = gauge.getValue(1);
if (current > 1 && Create.RANDOM.nextFloat() < 1 / 2f)
gauge.setValueNoUpdate(current + Math.min(-(current - 1) * Create.RANDOM.nextFloat(), 0));
if (current > 1 && level.random.nextFloat() < 1 / 2f)
gauge.setValueNoUpdate(current + Math.min(-(current - 1) * level.random.nextFloat(), 0));
return;
}
if (needsHeatLevelUpdate && updateTemperature(controller))

View file

@ -23,7 +23,6 @@ import com.simibubi.create.content.logistics.box.PackageEntity;
import com.simibubi.create.content.logistics.box.PackageItem;
import com.simibubi.create.content.logistics.packagePort.frogport.FrogportBlockEntity;
import com.simibubi.create.content.schematics.requirement.ItemRequirement;
import com.simibubi.create.content.schematics.requirement.ItemRequirement.ItemUseType;
import com.simibubi.create.foundation.utility.ServerSpeedProvider;
import com.simibubi.create.infrastructure.config.AllConfigs;
@ -692,6 +691,7 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements ITra
if (clientPacket && compound.contains("DestroyEffect") && level != null)
spawnDestroyParticles(NbtUtils.readBlockPos(compound.getCompound("DestroyEffect")));
int sizeBefore = connections.size();
connections.clear();
NBTHelper.iterateCompoundList(compound.getList("Connections", Tag.TAG_COMPOUND),
c -> connections.add(NbtUtils.readBlockPos(c)));
@ -704,6 +704,9 @@ public class ChainConveyorBlockEntity extends KineticBlockEntity implements ITra
connectionStats = null;
updateBoxWorldPositions();
updateChainShapes();
if (connections.size() != sizeBefore && level.isClientSide)
invalidateRenderBoundingBox();
}
public float wrapAngle(float angle) {

View file

@ -6,6 +6,8 @@ import com.simibubi.create.infrastructure.config.AllConfigs;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
@ -72,6 +74,8 @@ public class ChainConveyorConnectionPacket extends BlockEntityConfigurationPacke
}
}
be.chainDestroyed(targetPos.subtract(be.getBlockPos()), false, true);
be.getLevel()
.playSound(null, player.blockPosition(), SoundEvents.CHAIN_BREAK, SoundSource.BLOCKS);
}
if (connect) {

View file

@ -253,7 +253,7 @@ public class ChainConveyorRenderer extends KineticBlockEntityRenderer<ChainConve
@Override
public boolean shouldRenderOffScreen(ChainConveyorBlockEntity be) {
return !be.connections.isEmpty();
return true;
}
@Override

View file

@ -7,9 +7,11 @@ import com.simibubi.create.foundation.utility.ServerSpeedProvider;
import net.createmod.catnip.utility.AnimationTickHolder;
import net.createmod.catnip.utility.VecHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.Mth;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.phys.Vec3;
@ -33,6 +35,8 @@ public class ChainConveyorRidingHandler {
Component component = Component.translatable("mount.onboard", mc.options.keyShift.getTranslatedKeyMessage());
mc.gui.setOverlayMessage(component, false);
mc.getSoundManager()
.play(SimpleSoundInstance.forUI(SoundEvents.CHAIN_HIT, 1f, 0.5f));
}
public static void clientTick() {
@ -43,13 +47,11 @@ public class ChainConveyorRidingHandler {
return;
BlockEntity blockEntity = mc.level.getBlockEntity(ridingChainConveyor);
if (mc.player.isShiftKeyDown() || !(blockEntity instanceof ChainConveyorBlockEntity clbe)) {
ridingChainConveyor = null;
ridingConnection = null;
stopRiding();
return;
}
if (ridingConnection != null && !clbe.connections.contains(ridingConnection)) {
ridingChainConveyor = null;
ridingConnection = null;
stopRiding();
return;
}
@ -85,9 +87,8 @@ public class ChainConveyorRidingHandler {
catchingUp--;
Vec3 diff = targetPosition.subtract(playerPosition);
if (catchingUp == 0 && diff.length() > 3) {
ridingChainConveyor = null;
ridingConnection = null;
if (catchingUp == 0 && (diff.length() > 3 || diff.y < -1)) {
stopRiding();
return;
}
@ -96,7 +97,18 @@ public class ChainConveyorRidingHandler {
.add(diff.scale(0.25)));
if (AnimationTickHolder.getTicks() % 10 == 0)
AllPackets.getChannel()
.sendToServer(new ServerboundChainConveyorRidingPacket(ridingChainConveyor));
.sendToServer(new ServerboundChainConveyorRidingPacket(ridingChainConveyor, false));
}
private static void stopRiding() {
if (ridingChainConveyor != null)
AllPackets.getChannel()
.sendToServer(new ServerboundChainConveyorRidingPacket(ridingChainConveyor, true));
ridingChainConveyor = null;
ridingConnection = null;
Minecraft.getInstance()
.getSoundManager()
.play(SimpleSoundInstance.forUI(SoundEvents.CHAIN_HIT, 0.75f, 0.35f));
}
private static void updateTargetPosition(Minecraft mc, ChainConveyorBlockEntity clbe) {

View file

@ -25,6 +25,11 @@ public class ServerChainConveyorHandler {
if (hangingPlayers.size() != count)
sync();
}
public static void handleStopRidingPacket(Player player) {
if (hangingPlayers.removeInt(player.getUUID()) != 0)
sync();
}
public static void tick() {
ticks++;

View file

@ -1,6 +1,7 @@
package com.simibubi.create.content.kinetics.chainConveyor;
import com.simibubi.create.foundation.networking.BlockEntityConfigurationPacket;
import com.simibubi.create.infrastructure.config.AllConfigs;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
@ -8,8 +9,11 @@ import net.minecraft.server.level.ServerPlayer;
public class ServerboundChainConveyorRidingPacket extends BlockEntityConfigurationPacket<ChainConveyorBlockEntity> {
public ServerboundChainConveyorRidingPacket(BlockPos pos) {
private boolean stop;
public ServerboundChainConveyorRidingPacket(BlockPos pos, boolean stop) {
super(pos);
this.stop = stop;
}
public ServerboundChainConveyorRidingPacket(FriendlyByteBuf buffer) {
@ -17,11 +21,20 @@ public class ServerboundChainConveyorRidingPacket extends BlockEntityConfigurati
}
@Override
protected void writeSettings(FriendlyByteBuf buffer) {}
protected void writeSettings(FriendlyByteBuf buffer) {
buffer.writeBoolean(stop);
}
@Override
protected void readSettings(FriendlyByteBuf buffer) {}
protected void readSettings(FriendlyByteBuf buffer) {
stop = buffer.readBoolean();
}
@Override
protected int maxRange() {
return AllConfigs.server().kinetics.maxChainConveyorLength.get() * 2;
}
@Override
protected void applySettings(ChainConveyorBlockEntity be) {}
@ -30,7 +43,11 @@ public class ServerboundChainConveyorRidingPacket extends BlockEntityConfigurati
sender.fallDistance = 0;
sender.connection.aboveGroundTickCount = 0;
sender.connection.aboveGroundVehicleTickCount = 0;
ServerChainConveyorHandler.handleTTLPacket(sender);
if (stop)
ServerChainConveyorHandler.handleStopRidingPacket(sender);
else
ServerChainConveyorHandler.handleTTLPacket(sender);
}
}

View file

@ -35,6 +35,7 @@ import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Inventory;
@ -118,6 +119,8 @@ public class StockKeeperCategoryScreen extends AbstractSimiContainerScreen<Stock
if (editingItem == null)
return;
playUiSound(SoundEvents.UI_BUTTON_CLICK.get(), 1, 1);
removeWidget(editorConfirm);
removeWidget(editorEditBox);
@ -337,8 +340,10 @@ public class StockKeeperCategoryScreen extends AbstractSimiContainerScreen<Stock
if (x > 0 && x <= 16 && y > 0 && y <= 16) {
renderActionTooltip(graphics, ImmutableList.of(CreateLang.translate("gui.stock_ticker.new_category")
.component()), mx, my);
if (click == 0)
if (click == 0) {
playUiSound(SoundEvents.UI_BUTTON_CLICK.get(), 1f, 1f);
startEditing(-1);
}
}
return false;
@ -355,8 +360,10 @@ public class StockKeeperCategoryScreen extends AbstractSimiContainerScreen<Stock
stopEditing();
return true;
}
if (action(null, pMouseX, pMouseY, pButton))
if (action(null, pMouseX, pMouseY, pButton)) {
playUiSound(SoundEvents.UI_BUTTON_CLICK.get(), 1f, 1f);
return true;
}
boolean wasNotFocused = editorEditBox != null && !editorEditBox.isFocused();
boolean mouseClicked = super.mouseClicked(pMouseX, pMouseY, pButton);

View file

@ -22,6 +22,7 @@ import com.mojang.math.Axis;
import com.simibubi.create.AllBlocks;
import com.simibubi.create.AllPackets;
import com.simibubi.create.AllPartialModels;
import com.simibubi.create.AllSoundEvents;
import com.simibubi.create.AllTags.AllItemTags;
import com.simibubi.create.content.contraptions.actors.seat.SeatEntity;
import com.simibubi.create.content.equipment.clipboard.ClipboardEntry;
@ -59,6 +60,7 @@ import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.LivingEntity;
@ -252,6 +254,11 @@ public class StockKeeperRequestScreen extends AbstractSimiContainerScreen<StockK
extraAreas.add(new Rect2i(0, y + windowHeight - 15 - leftHeight, x, height));
if (encodeRequester)
extraAreas.add(new Rect2i(x + windowWidth, y + windowHeight - 15 - rightHeight, rightHeight, rightHeight));
if (initial) {
playUiSound(SoundEvents.WOOD_HIT, 0.5f, 1.5f);
playUiSound(SoundEvents.BOOK_PAGE_TURN, 1, 1);
}
}
private void refreshSearchResults(boolean scrollBackUp) {
@ -1018,6 +1025,7 @@ public class StockKeeperRequestScreen extends AbstractSimiContainerScreen<StockK
isLocked = !isLocked;
AllPackets.getChannel()
.sendToServer(new StockKeeperLockPacket(blockEntity.getBlockPos(), isLocked));
playUiSound(SoundEvents.UI_BUTTON_CLICK.get(), 1, 1);
return true;
}
@ -1033,6 +1041,7 @@ public class StockKeeperRequestScreen extends AbstractSimiContainerScreen<StockK
// Confirm
if (lmb && isConfirmHovered((int) pMouseX, (int) pMouseY)) {
sendIt();
playUiSound(SoundEvents.UI_BUTTON_CLICK.get(), 1, 1);
return true;
}
@ -1086,14 +1095,19 @@ public class StockKeeperRequestScreen extends AbstractSimiContainerScreen<StockK
if (itemsToOrder.size() >= cols || rmb)
return true;
itemsToOrder.add(existingOrder = new BigItemStack(itemStack.copyWithCount(1), 0));
playUiSound(SoundEvents.WOOL_STEP, 0.5f, 1.2f);
playUiSound(SoundEvents.BAMBOO_WOOD_STEP, 0.5f, 0.8f);
}
int current = existingOrder.count;
if (rmb || orderClicked) {
existingOrder.count = current - transfer;
if (existingOrder.count <= 0)
if (existingOrder.count <= 0) {
itemsToOrder.remove(existingOrder);
playUiSound(SoundEvents.WOOL_STEP, 0.5f, 1.8f);
playUiSound(SoundEvents.BAMBOO_WOOD_STEP, 0.5f, 1.8f);
}
return true;
}
@ -1145,19 +1159,29 @@ public class StockKeeperRequestScreen extends AbstractSimiContainerScreen<StockK
if (itemsToOrder.size() >= cols || remove)
return true;
itemsToOrder.add(existingOrder = new BigItemStack(entry.stack.copyWithCount(1), 0));
playUiSound(SoundEvents.WOOL_STEP, 0.5f, 1.2f);
playUiSound(SoundEvents.BAMBOO_WOOD_STEP, 0.5f, 0.8f);
}
int current = existingOrder.count;
if (remove) {
existingOrder.count = current - transfer;
if (existingOrder.count <= 0)
if (existingOrder.count <= 0) {
itemsToOrder.remove(existingOrder);
playUiSound(SoundEvents.WOOL_STEP, 0.5f, 1.8f);
playUiSound(SoundEvents.BAMBOO_WOOD_STEP, 0.5f, 1.8f);
} else if (existingOrder.count != current)
playUiSound(AllSoundEvents.SCROLL_VALUE.getMainEvent(), 0.25f, 1.2f);
return true;
}
existingOrder.count = current + Math.min(transfer, blockEntity.getLastClientsideStockSnapshotAsSummary()
.getCountOf(entry.stack) - current);
if (existingOrder.count != current && current != 0)
playUiSound(AllSoundEvents.SCROLL_VALUE.getMainEvent(), 0.25f, 1.2f);
return true;
}

View file

@ -11,6 +11,7 @@ import com.simibubi.create.foundation.gui.AllGuiTextures;
import net.createmod.catnip.gui.TickableGuiEventListener;
import net.createmod.catnip.gui.widget.AbstractSimiWidget;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.EditBox;
@ -20,7 +21,9 @@ import net.minecraft.client.gui.narration.NarratableEntry;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
import net.minecraft.client.gui.screens.inventory.ContainerScreen;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraftforge.api.distmarker.Dist;
@ -182,4 +185,10 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
}
}
protected void playUiSound(SoundEvent sound, float volume, float pitch) {
Minecraft.getInstance()
.getSoundManager()
.play(SimpleSoundInstance.forUI(sound, pitch, volume * 0.25f));
}
}