diff --git a/src/main/java/me/desht/pneumaticcraft/client/gui/MinigunMagazineScreen.java b/src/main/java/me/desht/pneumaticcraft/client/gui/MinigunMagazineScreen.java index 0cbdd0f47..45043e977 100644 --- a/src/main/java/me/desht/pneumaticcraft/client/gui/MinigunMagazineScreen.java +++ b/src/main/java/me/desht/pneumaticcraft/client/gui/MinigunMagazineScreen.java @@ -17,6 +17,7 @@ package me.desht.pneumaticcraft.client.gui; +import me.desht.pneumaticcraft.client.util.ClientUtils; import me.desht.pneumaticcraft.client.util.GuiUtils; import me.desht.pneumaticcraft.common.block.entity.AbstractPneumaticCraftBlockEntity; import me.desht.pneumaticcraft.common.inventory.MinigunMagazineMenu; @@ -45,7 +46,7 @@ public void init() { addInfoTab(GuiUtils.xlateAndSplit("gui.tooltip.item.pneumaticcraft.minigun")); addAnimatedStat(xlate("pneumaticcraft.gui.tab.minigun.slotInfo.title"), new ItemStack(ModItems.GUN_AMMO.get()), 0xFF0080C0, true) - .setText(GuiUtils.xlateAndSplit("pneumaticcraft.gui.tab.minigun.slotInfo")); + .setText(GuiUtils.xlateAndSplit("pneumaticcraft.gui.tab.minigun.slotInfo", ClientUtils.translateKeyBind(Minecraft.getInstance().options.keyPickItem))); } @Override diff --git a/src/main/java/me/desht/pneumaticcraft/client/util/GuiUtils.java b/src/main/java/me/desht/pneumaticcraft/client/util/GuiUtils.java index f49a195b9..e886f9b24 100644 --- a/src/main/java/me/desht/pneumaticcraft/client/util/GuiUtils.java +++ b/src/main/java/me/desht/pneumaticcraft/client/util/GuiUtils.java @@ -34,7 +34,6 @@ import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.client.renderer.texture.TextureAtlas; import net.minecraft.client.renderer.texture.TextureAtlasSprite; -import net.minecraft.client.resources.language.I18n; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import net.minecraft.util.FormattedCharSequence; @@ -239,7 +238,7 @@ public static List wrapTextComponentList(List } public static List xlateAndSplit(String key, Object... params) { - return Arrays.stream(StringUtils.splitByWholeSeparator(I18n.get(key, params), TRANSLATION_LINE_BREAK)) + return Arrays.stream(StringUtils.splitByWholeSeparator(Component.translatable(key, params).getString(), TRANSLATION_LINE_BREAK)) .map(Component::literal) .collect(Collectors.toList()); } diff --git a/src/main/java/me/desht/pneumaticcraft/common/inventory/MinigunMagazineMenu.java b/src/main/java/me/desht/pneumaticcraft/common/inventory/MinigunMagazineMenu.java index d9cf5508e..34f834d34 100644 --- a/src/main/java/me/desht/pneumaticcraft/common/inventory/MinigunMagazineMenu.java +++ b/src/main/java/me/desht/pneumaticcraft/common/inventory/MinigunMagazineMenu.java @@ -31,6 +31,8 @@ import net.minecraft.world.item.ItemStack; import net.neoforged.neoforge.items.SlotItemHandler; +import static me.desht.pneumaticcraft.common.item.minigun.MinigunItem.NOT_LOCKED; + public class MinigunMagazineMenu extends AbstractPneumaticCraftMenu { private final MinigunItem.MagazineHandler gunInv; private final InteractionHand hand; @@ -66,16 +68,12 @@ public boolean stillValid(Player player) { @Override public void clicked(int slotId, int dragType, ClickType clickType, Player player) { - if (clickType == ClickType.CLONE && dragType == 2 && slotId >= 0 && slotId < MinigunItem.MAGAZINE_SIZE) { - // middle-click to lock a slot + if (clickType == ClickType.CLONE && slotId >= 0 && slotId < MinigunItem.MAGAZINE_SIZE) { + // middle-click (or whatever "pick block" is bound to) to lock a slot ItemStack gunStack = player.getItemInHand(hand); if (gunStack.getItem() instanceof MinigunItem) { int slot = MinigunItem.getLockedSlot(gunStack); - if (slot == slotId) { - gunStack.remove(ModDataComponents.MINIGUN_LOCKED_SLOT); - } else { - gunStack.set(ModDataComponents.MINIGUN_LOCKED_SLOT, slotId); - } + gunStack.set(ModDataComponents.MINIGUN_LOCKED_SLOT, slot == slotId ? NOT_LOCKED : slotId); if (player.level().isClientSide) { player.playSound(SoundEvents.UI_BUTTON_CLICK.value(), 0.5f, 1.0f); } diff --git a/src/main/java/me/desht/pneumaticcraft/common/item/minigun/MinigunItem.java b/src/main/java/me/desht/pneumaticcraft/common/item/minigun/MinigunItem.java index 375902341..a1a9855f6 100644 --- a/src/main/java/me/desht/pneumaticcraft/common/item/minigun/MinigunItem.java +++ b/src/main/java/me/desht/pneumaticcraft/common/item/minigun/MinigunItem.java @@ -85,7 +85,7 @@ public class MinigunItem extends PressurizableItem implements IChargeableContainerProvider, IFOVModifierItem, IInventoryItem, IShiftScrollable { public static final int MAGAZINE_SIZE = 4; - private static final int NOT_LOCKED = -1; + public static final int NOT_LOCKED = -1; public MinigunItem() { super(ModItems.toolProps().component(ModDataComponents.MINIGUN_LOCKED_SLOT, NOT_LOCKED), diff --git a/src/main/resources/assets/pneumaticcraft/lang/en_us.json b/src/main/resources/assets/pneumaticcraft/lang/en_us.json index e77edac55..46bd80f15 100644 --- a/src/main/resources/assets/pneumaticcraft/lang/en_us.json +++ b/src/main/resources/assets/pneumaticcraft/lang/en_us.json @@ -1670,7 +1670,7 @@ "pneumaticcraft.gui.tab.liquidCompressor.fuel" : "Available Fuels", "pneumaticcraft.gui.tab.liquidHopper.mode.empty" : "Empty out tank.", "pneumaticcraft.gui.tab.liquidHopper.mode.leaveLiquid" : "Leave 1000mB in tank, to filter.", - "pneumaticcraft.gui.tab.minigun.slotInfo" : "The Minigun will normally draw ammo from the lowest-numbered slot which contains any ammo.\n\n§aMiddle-click§f a slot to lock that slot: when locked, the Minigun will draw ammo from that slot only. §aMiddle-click§f a locked slot to unlock it.\n\nLocking slots is useful if you're carrying multiple ammo types.", + "pneumaticcraft.gui.tab.minigun.slotInfo" : "The Minigun will normally draw ammo from the lowest-numbered slot which contains any ammo.\n\nPress §a%s§f on a slot to toggle locking that slot: when locked, the Minigun will draw ammo from that slot only.\n\nLocking slots is useful if you're carrying multiple ammo types.", "pneumaticcraft.gui.tab.minigun.slotInfo.title" : "Ammo Management", "pneumaticcraft.gui.tab.omnidirectionalHopper.mode.empty" : "Normal Hopper Operation.", "pneumaticcraft.gui.tab.omnidirectionalHopper.mode.leaveItem" : "Leave one item per slot, to filter.",