From 560042d781807249ff47016f5bcbb908cc5004dc Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Sun, 10 Jul 2022 15:14:58 +0200 Subject: [PATCH] Lang sendStatus --- .../glue/SuperGlueSelectionHandler.java | 37 +++++++++++++------ .../mounted/CartAssemblerBlockItem.java | 5 ++- .../item/LinkedControllerClientHandler.java | 5 ++- .../client/SchematicAndQuillHandler.java | 22 +++++++---- .../create/foundation/utility/Lang.java | 11 ------ 5 files changed, 46 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueSelectionHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueSelectionHandler.java index fa387da25..ca772f793 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueSelectionHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueSelectionHandler.java @@ -115,7 +115,9 @@ public class SuperGlueSelectionHandler { } if (firstPos != null && !firstPos.closerThan(hovered, 24)) { - Lang.sendStatus(player, FAIL, "super_glue.too_far"); + Lang.translate("super_glue.too_far") + .color(FAIL) + .sendStatus(player); return; } @@ -131,15 +133,23 @@ public class SuperGlueSelectionHandler { if (currentCluster != null) { boolean canReach = currentCluster.contains(hovered); boolean canAfford = SuperGlueSelectionHelper.collectGlueFromInventory(player, glueRequired, true); + int color = HIGHLIGHT; + String key = "super_glue.click_to_confirm"; - if (!canReach) - Lang.sendStatus(player, FAIL, "super_glue.cannot_reach"); - else if (!canAfford) - Lang.sendStatus(player, FAIL, "super_glue.not_enough"); - else if (cancel) - Lang.sendStatus(player, FAIL, "super_glue.click_to_discard"); - else - Lang.sendStatus(player, HIGHLIGHT, "super_glue.click_to_confirm"); + if (!canReach) { + color = FAIL; + key = "super_glue.cannot_reach"; + } else if (!canAfford) { + color = FAIL; + key = "super_glue.not_enough"; + } else if (cancel) { + color = FAIL; + key = "super_glue.click_to_discard"; + } + + Lang.translate(key) + .color(color) + .sendStatus(player); if (currentSelectionBox != null) CreateClient.OUTLINER.showAABB(bbOutlineSlot, currentSelectionBox) @@ -223,7 +233,8 @@ public class SuperGlueSelectionHandler { firstPos = hoveredPos; if (face != null) SuperGlueItem.spawnParticles(level, firstPos, face, true); - Lang.sendStatus(player, "super_glue.first_pos"); + Lang.translate("super_glue.first_pos") + .sendStatus(player); AllSoundEvents.SLIME_ADDED.playAt(level, firstPos, 0.5F, 0.85F, false); level.playSound(player, firstPos, SoundEvents.ITEM_FRAME_ADD_ITEM, SoundSource.BLOCKS, 0.75f, 1); return true; @@ -233,7 +244,8 @@ public class SuperGlueSelectionHandler { LocalPlayer player = Minecraft.getInstance().player; currentCluster = null; firstPos = null; - Lang.sendStatus(player, "super_glue.abort"); + Lang.translate("super_glue.abort") + .sendStatus(player); clusterCooldown = 0; } @@ -251,7 +263,8 @@ public class SuperGlueSelectionHandler { .lineWidth(1 / 24f); discard(); - Lang.sendStatus(player, "super_glue.sucess"); + Lang.translate("super_glue.success") + .sendStatus(player); clusterCooldown = 40; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java index 0d30e871d..7482573da 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/mounted/CartAssemblerBlockItem.java @@ -49,7 +49,8 @@ public class CartAssemblerBlockItem extends BlockItem { if (player == null) return false; if (!(block instanceof BaseRailBlock)) { - Lang.sendStatus(player, "block.cart_assembler.invalid"); + Lang.translate("block.cart_assembler.invalid") + .sendStatus(player); return false; } @@ -81,7 +82,7 @@ public class CartAssemblerBlockItem extends BlockItem { if (!player.isCreative()) context.getItemInHand() .shrink(1); - + AdvancementBehaviour.setPlacedBy(world, pos, player); return true; } diff --git a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java index 06b490716..25ea8591d 100644 --- a/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/item/LinkedControllerClientHandler.java @@ -196,9 +196,10 @@ public class LinkedControllerClientHandler { LinkBehaviour linkBehaviour = TileEntityBehaviour.get(mc.level, selectedLocation, LinkBehaviour.TYPE); if (linkBehaviour != null) { AllPackets.channel.sendToServer(new LinkedControllerBindPacket(integer, selectedLocation)); - Lang.sendStatus(mc.player, "linked_controller.key_bound", controls.get(integer) + Lang.translate("linked_controller.key_bound", controls.get(integer) .getTranslatedKeyMessage() - .getString()); + .getString()) + .sendStatus(mc.player); } MODE = Mode.IDLE; break; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java index 8e820742f..220ce6699 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java @@ -90,8 +90,10 @@ public class SchematicAndQuillHandler { firstPos = new BlockPos(bb.minX, bb.minY, bb.minZ); secondPos = new BlockPos(bb.maxX, bb.maxY, bb.maxZ); - Lang.sendStatus(Minecraft.getInstance().player, "schematicAndQuill.dimensions", (int) bb.getXsize() + 1, - (int) bb.getYsize() + 1, (int) bb.getZsize() + 1); + LocalPlayer player = Minecraft.getInstance().player; + Lang.translate("schematicAndQuill.dimensions", (int) bb.getXsize() + 1, (int) bb.getYsize() + 1, + (int) bb.getZsize() + 1) + .sendStatus(player); return true; } @@ -115,25 +117,29 @@ public class SchematicAndQuillHandler { } if (selectedPos == null) { - Lang.sendStatus(player, "schematicAndQuill.noTarget"); + Lang.translate("schematicAndQuill.noTarget") + .sendStatus(player); return; } if (firstPos != null) { secondPos = selectedPos; - Lang.sendStatus(player, "schematicAndQuill.secondPos"); + Lang.translate("schematicAndQuill.secondPos") + .sendStatus(player); return; } firstPos = selectedPos; - Lang.sendStatus(player, "schematicAndQuill.firstPos"); + Lang.translate("schematicAndQuill.firstPos") + .sendStatus(player); } public void discard() { LocalPlayer player = Minecraft.getInstance().player; firstPos = null; secondPos = null; - Lang.sendStatus(player, "schematicAndQuill.abort"); + Lang.translate("schematicAndQuill.abort") + .sendStatus(player); } public void tick() { @@ -239,7 +245,9 @@ public class SchematicAndQuillHandler { } firstPos = null; secondPos = null; - Lang.sendStatus(Minecraft.getInstance().player, "schematicAndQuill.saved", filepath); + LocalPlayer player = Minecraft.getInstance().player; + Lang.translate("schematicAndQuill.saved", filepath) + .sendStatus(player); if (!convertImmediately) return; diff --git a/src/main/java/com/simibubi/create/foundation/utility/Lang.java b/src/main/java/com/simibubi/create/foundation/utility/Lang.java index de346c8a4..3e062b8bb 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Lang.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Lang.java @@ -9,7 +9,6 @@ import com.simibubi.create.Create; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.TextComponent; import net.minecraft.network.chat.TranslatableComponent; -import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.block.state.BlockState; import net.minecraftforge.fluids.FluidStack; @@ -27,16 +26,6 @@ public class Lang { return new TranslatableComponent(Create.ID + "." + key, resolveBuilders(args)); } - @Deprecated // use Lang.translate(...).sendStatus(player) - public static void sendStatus(Player player, String key, Object... args) { - translate(key, args).sendStatus(player); - } - - @Deprecated // use Lang.translate(...).color(color).sendStatus(player) - public static void sendStatus(Player player, int color, String key, Object... args) { - translate(key, args).color(color).sendStatus(player); - } - public static String asId(String name) { return name.toLowerCase(Locale.ROOT); }