]> git.lizzy.rs Git - BoundingBoxOutlineReloaded.git/commitdiff
Support translations
authorIrtimaled <irtimaled@gmail.com>
Wed, 6 May 2020 07:01:13 +0000 (00:01 -0700)
committerIrtimaled <irtimaled@gmail.com>
Mon, 18 May 2020 00:28:01 +0000 (17:28 -0700)
12 files changed:
src/main/java/com/irtimaled/bbor/client/ClientProxy.java
src/main/java/com/irtimaled/bbor/client/commands/BoxCommand.java
src/main/java/com/irtimaled/bbor/client/commands/CommandHelper.java
src/main/java/com/irtimaled/bbor/client/commands/SeedCommand.java
src/main/java/com/irtimaled/bbor/client/commands/SpawningSphereCommand.java
src/main/java/com/irtimaled/bbor/client/gui/IntSettingSlider.java
src/main/java/com/irtimaled/bbor/client/gui/MaxYSettingSlider.java
src/main/java/com/irtimaled/bbor/client/gui/SettingsScreen.java
src/main/java/com/irtimaled/bbor/client/interop/ModPackFinder.java [new file with mode: 0644]
src/main/java/com/irtimaled/bbor/client/renderers/SpawningSphereRenderer.java
src/main/java/com/irtimaled/bbor/mixin/client/MixinMinecraft.java
src/main/resources/assets/bbor/lang/en_us.json [new file with mode: 0644]

index 9e124c85190c1b47d45714523452a5a5b8f7d2d7..1114e0151b4fa50eaefc0143c955c69a8860ea8b 100644 (file)
@@ -13,7 +13,7 @@ import com.irtimaled.bbor.config.ConfigManager;
 
 public class ClientProxy extends CommonProxy {
     static {
-        Key mainKey = KeyListener.register("Toggle Active", "key.keyboard.b")
+        Key mainKey = KeyListener.register("bbor.key.toggleActive", "key.keyboard.b")
                 .onKeyPressHandler(ClientRenderer::toggleActive);
         mainKey.register("key.keyboard.g")
                 .onKeyPressHandler(SettingsScreen::show);
index 6a67cea8a4e585b79c9c07867dc83001c7aa9d81..29d50a45b2400b78cae1fd49bf472efdb14e7fb1 100644 (file)
@@ -4,7 +4,6 @@ import com.irtimaled.bbor.client.providers.CustomBoxProvider;
 import com.irtimaled.bbor.common.models.Coords;
 import com.mojang.brigadier.CommandDispatcher;
 import com.mojang.brigadier.builder.LiteralArgumentBuilder;
-import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 import net.minecraft.command.Commands;
 import net.minecraft.command.ISuggestionProvider;
 import net.minecraft.command.arguments.BlockPosArgument;
@@ -29,15 +28,16 @@ public class BoxCommand {
                                             Coords maxCoords = getMaxCoords(from, to);
                                             CustomBoxProvider.add(minCoords, maxCoords);
 
-                                            String feedback = getPosBasedFeedback("Box added", from, to);
-                                            CommandHelper.feedback(context, feedback);
+                                            CommandHelper.feedback(context, "bbor.commands.box.added",
+                                                    from.getX(), from.getY(), from.getZ(),
+                                                    to.getX(), to.getY(), to.getZ());
                                             return 0;
                                         }))))
                 .then(Commands.literal(CLEAR)
                         .executes(context -> {
                             CustomBoxProvider.clear();
 
-                            CommandHelper.feedback(context, "All boxes cleared");
+                            CommandHelper.feedback(context, "bbor.commands.box.cleared.all");
                             return 0;
                         })
                         .then(Commands.argument(FROM, BlockPosArgument.blockPos())
@@ -49,14 +49,12 @@ public class BoxCommand {
                                             Coords maxCoords = getMaxCoords(from, to);
                                             boolean removed = CustomBoxProvider.remove(minCoords, maxCoords);
 
-                                            String prefix = removed ? "Box cleared" : "No box found";
-                                            String feedback = getPosBasedFeedback(prefix, from, to);
-                                            CommandHelper.feedback(context, feedback);
+                                            String format = removed ? "bbor.commands.box.cleared" : "bbor.commands.box.notFound";
+                                            CommandHelper.feedback(context, format,
+                                                    from.getX(), from.getY(), from.getZ(),
+                                                    to.getX(), to.getY(), to.getZ());
                                             return 0;
-                                        }))))
-                .executes(context -> {
-                    throw INCOMPLETE_COMMAND.create();
-                });
+                                        }))));
         commandDispatcher.register(command);
     }
 
@@ -67,11 +65,4 @@ public class BoxCommand {
     private static Coords getMinCoords(BlockPos from, BlockPos to) {
         return new Coords(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
     }
-
-    private static String getPosBasedFeedback(String prefix, BlockPos from, BlockPos to) {
-        return String.format("%s with start [%d, %d, %d] and end [%d, %d, %d]", prefix, from.getX(), from.getY(), from.getZ(), to.getX(), to.getY(), to.getZ());
-    }
-
-    private static final SimpleCommandExceptionType INCOMPLETE_COMMAND =
-            CommandHelper.getIncompleteCommandException(COMMAND, ADD, CLEAR);
 }
index 294c6927146234d90529ea3e9364c610e65e6a93..cdb7260e1b6dd5c7738a3a67f546cf3aec433381 100644 (file)
@@ -1,37 +1,11 @@
 package com.irtimaled.bbor.client.commands;
 
 import com.mojang.brigadier.context.CommandContext;
-import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 import net.minecraft.command.CommandSource;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraft.util.text.TextComponentString;
-import net.minecraft.util.text.TextFormatting;
-import net.minecraft.util.text.event.ClickEvent;
+import net.minecraft.util.text.TextComponentTranslation;
 
 class CommandHelper {
-    static SimpleCommandExceptionType getIncompleteCommandException(String cmd, String... commands) {
-        ITextComponent textComponent = new TextComponentString("Incomplete command");
-
-        int length = commands.length;
-        if (length > 0) {
-            textComponent.appendText(" (expected ");
-            for (int idx = 0; idx < length; idx++) {
-                if (idx > 0) textComponent.appendText(", ");
-                if (idx + 1 == length) textComponent.appendText("or ");
-                String command = commands[idx];
-                String commandSuggestion = String.format("/%s %s", cmd, command);
-                ClickEvent clickEvent = new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, commandSuggestion);
-                ITextComponent suggestion = new TextComponentString(command)
-                        .applyTextStyle(TextFormatting.UNDERLINE)
-                        .applyTextStyle(style -> style.setClickEvent(clickEvent));
-                textComponent.appendSibling(suggestion);
-            }
-            textComponent.appendText(")");
-        }
-        return new SimpleCommandExceptionType(textComponent);
-    }
-
-    static void feedback(CommandContext<CommandSource> context, String feedback) {
-        context.getSource().sendFeedback(new TextComponentString(feedback), false);
+    static void feedback(CommandContext<CommandSource> context, String format, Object... values) {
+        context.getSource().sendFeedback(new TextComponentTranslation(format, values), false);
     }
 }
index a25e04c340beb1276e2f445c6832947880f3d8a1..9937a161a2f069ded5303d74179f6f429d179ca7 100644 (file)
@@ -2,13 +2,10 @@ package com.irtimaled.bbor.client.commands;
 
 import com.irtimaled.bbor.client.providers.SlimeChunkProvider;
 import com.mojang.brigadier.CommandDispatcher;
-import com.mojang.brigadier.StringReader;
 import com.mojang.brigadier.arguments.StringArgumentType;
 import com.mojang.brigadier.builder.LiteralArgumentBuilder;
-import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 import net.minecraft.command.Commands;
 import net.minecraft.command.ISuggestionProvider;
-import net.minecraft.util.text.TextComponentString;
 
 public class SeedCommand {
     private static final String COMMAND = "bbor:seed";
@@ -21,10 +18,7 @@ public class SeedCommand {
                             String argument = StringArgumentType.getString(context, SEED);
                             handleSeedCommand(argument);
                             return 0;
-                        }))
-                .executes(context -> {
-                    throw INCOMPLETE_COMMAND.createWithContext(new StringReader(context.getInput()));
-                });
+                        }));
         commandDispatcher.register(command);
     }
 
@@ -43,8 +37,4 @@ public class SeedCommand {
             return null;
         }
     }
-
-    private static final SimpleCommandExceptionType INCOMPLETE_COMMAND =
-            new SimpleCommandExceptionType(new TextComponentString("Missing argument (expected seed)"));
-
 }
index 625a7d4f5545389c08b2475e98ac45f2fad4e38e..a97c360fb27ea79f0a3a283437a8fe41ee281b2a 100644 (file)
@@ -3,7 +3,6 @@ package com.irtimaled.bbor.client.commands;
 import com.irtimaled.bbor.client.providers.SpawningSphereProvider;
 import com.mojang.brigadier.CommandDispatcher;
 import com.mojang.brigadier.builder.LiteralArgumentBuilder;
-import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
 import net.minecraft.command.Commands;
 import net.minecraft.command.ISuggestionProvider;
 import net.minecraft.command.arguments.Vec3Argument;
@@ -24,38 +23,32 @@ public class SpawningSphereCommand {
                                     Vec3d pos = Vec3Argument.getVec3(context, POS);
                                     SpawningSphereProvider.setSphere(pos.x, pos.y, pos.z);
 
-                                    CommandHelper.feedback(context, "Spawning sphere set");
+                                    CommandHelper.feedback(context, "bbor.commands.spawningSphere.set");
                                     return 0;
                                 }))
                         .executes(context -> {
                             Vec3d pos = context.getSource().getPos();
                             SpawningSphereProvider.setSphere(pos.x, pos.y, pos.z);
 
-                            CommandHelper.feedback(context, "Spawning sphere set");
+                            CommandHelper.feedback(context, "bbor.commands.spawningSphere.set");
                             return 0;
                         }))
                 .then(Commands.literal(CLEAR)
                         .executes(context -> {
                             boolean cleared = SpawningSphereProvider.clear();
 
-                            String feedback = cleared ? "Spawning sphere cleared" : "No spawning sphere set";
-                            CommandHelper.feedback(context, feedback);
+                            String format = cleared ? "bbor.commands.spawningSphere.cleared" : "bbor.commands.spawningSphere.notSet";
+                            CommandHelper.feedback(context, format);
                             return 0;
                         }))
                 .then(Commands.literal(CALCULATE_SPAWNABLE)
                         .executes(context -> {
                             int count = SpawningSphereProvider.recalculateSpawnableSpacesCount();
 
-                            String feedback = count == -1 ? "No spawning sphere set" : String.format("Calculated %,d spawnable spaces", count);
-                            CommandHelper.feedback(context, feedback);
+                            String format = count == -1 ? "bbor.commands.spawningSphere.notSet" : "bbor.commands.spawningSphere.calculated";
+                            CommandHelper.feedback(context, format, String.format("%,d", count));
                             return 0;
-                        }))
-                .executes(context -> {
-                    throw INCOMPLETE_COMMAND.create();
-                });
+                        }));
         commandDispatcher.register(command);
     }
-
-    private static final SimpleCommandExceptionType INCOMPLETE_COMMAND =
-            CommandHelper.getIncompleteCommandException(COMMAND, SET, CLEAR, CALCULATE_SPAWNABLE);
 }
index 777572964edbea0eac0af9c7b3d4b47874f68f1a..14f0ba9d6172b1ad961829467788bcc3f3d1d22b 100644 (file)
@@ -1,23 +1,24 @@
 package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.config.Setting;
+import net.minecraft.client.resources.I18n;
 
 import java.util.HashMap;
 import java.util.Map;
 
 class IntSettingSlider extends AbstractSlider implements IRenderableControl {
-    private final String prefix;
+    private final String format;
     private final Map<Integer, String> displayValues = new HashMap<>();
 
     final Setting<Integer> setting;
     final int minValue;
     final int range;
 
-    IntSettingSlider(int id, int x, int y, int width, int minValue, int maxValue, String prefix, Setting<Integer> setting) {
+    IntSettingSlider(int id, int x, int y, int width, int minValue, int maxValue, String format, Setting<Integer> setting) {
         super(id, x, y, width);
         this.setting = setting;
         this.minValue = minValue;
-        this.prefix = prefix;
+        this.format = format;
         this.range = maxValue - minValue;
         this.setProgress(getSliderValue());
         this.updateText();
@@ -33,7 +34,7 @@ class IntSettingSlider extends AbstractSlider implements IRenderableControl {
 
     private String getDisplayValue() {
         Integer value = setting.get();
-        return prefix + ": " + displayValues.getOrDefault(value, value.toString());
+        return I18n.format(format, displayValues.getOrDefault(value, value.toString()));
     }
 
     protected Integer getSettingValue() {
index e76b98effc751906fb3914a2a2002c49414a41b9..f6494eb84d606a88da2aacd6d92d07baa3cdcde1 100644 (file)
@@ -1,17 +1,18 @@
 package com.irtimaled.bbor.client.gui;
 
 import com.irtimaled.bbor.config.Setting;
+import net.minecraft.client.resources.I18n;
 
 class MaxYSettingSlider extends IntSettingSlider {
     private final int actualMinValue;
 
     MaxYSettingSlider(int id, int x, int y, int width, int minValue, Setting<Integer> setting) {
-        super(id, x, y, width, minValue - 2, 127, "Max Y", setting);
+        super(id, x, y, width, minValue - 2, 127, I18n.format("bbor.options.maxY", "%s"), setting);
         this.actualMinValue = minValue;
         this.setProgress(getSliderValue());
-        this.addDisplayValue(-1, "Activated");
-        this.addDisplayValue(0, "Player");
-        this.addDisplayValue(63, "Sea Level");
+        this.addDisplayValue(-1, I18n.format("bbor.options.maxY.activated"));
+        this.addDisplayValue(0, I18n.format("bbor.options.maxY.player"));
+        this.addDisplayValue(63, I18n.format("bbor.options.maxY.seaLevel"));
     }
 
     @Override
index c777e0983426ec9b460d71d983953176571a741a..4a55d9128e6bd94d65591cfd36b6bd97bb8fa671 100644 (file)
@@ -10,6 +10,7 @@ import net.minecraft.client.gui.Gui;
 import net.minecraft.client.gui.GuiScreen;
 import net.minecraft.client.gui.IGuiEventListener;
 import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.resources.I18n;
 import org.lwjgl.opengl.GL11;
 
 import java.util.HashSet;
@@ -59,7 +60,7 @@ public class SettingsScreen extends GuiScreen {
         }
 
         //done button
-        addControl(new AbstractButton(200, this.width / 2 - 100, getY(5.5), 200, "Done") {
+        addControl(new AbstractButton(200, this.width / 2 - 100, getY(5.5), 200, I18n.format("gui.done")) {
             @Override
             public void onPressed() {
                 ConfigManager.saveConfig();
@@ -113,10 +114,12 @@ public class SettingsScreen extends GuiScreen {
         this.title = "Bounding Box Outline Reloaded";
 
         this.controls = new HashSet<>();
-        this.addTabs("General", "Structures", "Villages");
+        this.addTabs(I18n.format("bbor.tabs.general"),
+                I18n.format("bbor.tabs.structures"),
+                I18n.format("bbor.tabs.villages"));
 
         buildTab(0,
-                (id, x, y, width) -> new AbstractButton(id, x, y, width, "Active", this.mc.world != null) {
+                (id, x, y, width) -> new AbstractButton(id, x, y, width, I18n.format("bbor.options.active"), this.mc.world != null) {
                     @Override
                     public void onPressed() {
                         ClientRenderer.toggleActive();
@@ -127,66 +130,66 @@ public class SettingsScreen extends GuiScreen {
                         return enabled ? ClientRenderer.getActive() ? 2 : 1 : 0;
                     }
                 },
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Outer Box Only", ConfigManager.outerBoxesOnly),
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Fill", ConfigManager.fill),
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.options.outerBoxOnly"), ConfigManager.outerBoxesOnly),
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.options.fill"), ConfigManager.fill),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Spawn Chunks", BoundingBoxType.WorldSpawn),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Lazy Chunks", BoundingBoxType.LazySpawnChunks),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.features.spawnChunks"), BoundingBoxType.WorldSpawn),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.features.lazyChunks"), BoundingBoxType.LazySpawnChunks),
                 (id, x, y, width) -> new MaxYSettingSlider(id, x, y, width, 39, ConfigManager.worldSpawnMaxY),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Slime Chunks", BoundingBoxType.SlimeChunks),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.features.slimeChunks"), BoundingBoxType.SlimeChunks),
                 (id, x, y, width) -> new MaxYSettingSlider(id, x, y, width, 39, ConfigManager.slimeChunkMaxY),
                 (id, x, y, width) -> (IRowHeight) () -> 0,
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Mob Spawners", BoundingBoxType.MobSpawner),
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Spawn Area", ConfigManager.renderMobSpawnerSpawnArea),
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Activation Lines", ConfigManager.renderMobSpawnerActivationLines),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.features.mobSpawners"), BoundingBoxType.MobSpawner),
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.features.mobSpawners.spawnArea"), ConfigManager.renderMobSpawnerSpawnArea),
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.features.mobSpawners.activationLines"), ConfigManager.renderMobSpawnerActivationLines),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Spawn Sphere", BoundingBoxType.AFKSphere),
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Spawnable Blocks", ConfigManager.renderAFKSpawnableBlocks),
-                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 3, "Distance", ConfigManager.afkSpawnableBlocksRenderDistance)
-                        .addDisplayValue(1, "Nearest")
-                        .addDisplayValue(2, "Nearer")
-                        .addDisplayValue(3, "Normal"),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.features.spawningSpheres"), BoundingBoxType.AFKSphere),
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.features.spawningSpheres.spawnableBlocks"), ConfigManager.renderAFKSpawnableBlocks),
+                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 3, "bbor.options.distance", ConfigManager.afkSpawnableBlocksRenderDistance)
+                        .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
+                        .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
+                        .addDisplayValue(3, I18n.format("bbor.options.distance.normal")),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Biome Borders", BoundingBoxType.BiomeBorder),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.features.biomeBorders"), BoundingBoxType.BiomeBorder),
                 (id, x, y, width) -> new MaxYSettingSlider(id, x, y, width, 1, ConfigManager.biomeBordersMaxY),
-                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 3, "Distance", ConfigManager.biomeBordersRenderDistance)
-                        .addDisplayValue(1, "Nearest")
-                        .addDisplayValue(2, "Nearer")
-                        .addDisplayValue(3, "Normal"));
+                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 3, "bbor.options.distance", ConfigManager.biomeBordersRenderDistance)
+                        .addDisplayValue(1, I18n.format("bbor.options.distance.nearest"))
+                        .addDisplayValue(2, I18n.format("bbor.options.distance.nearer"))
+                        .addDisplayValue(3, I18n.format("bbor.options.distance.normal")));
         buildTab(1,
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Desert Temples", BoundingBoxType.DesertTemple),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Jungle Temples", BoundingBoxType.JungleTemple),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Witch Huts", BoundingBoxType.WitchHut),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.desertTemples"), BoundingBoxType.DesertTemple),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.jungleTemples"), BoundingBoxType.JungleTemple),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.witchHuts"), BoundingBoxType.WitchHut),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Mansions", BoundingBoxType.Mansion),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Monuments", BoundingBoxType.OceanMonument),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Igloos", BoundingBoxType.Igloo),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.mansions"), BoundingBoxType.Mansion),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.monuments"), BoundingBoxType.OceanMonument),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.igloos"), BoundingBoxType.Igloo),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Ocean Ruins", BoundingBoxType.OceanRuin),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Buried Treasure", BoundingBoxType.BuriedTreasure),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Shipwrecks", BoundingBoxType.Shipwreck),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.oceanRuins"), BoundingBoxType.OceanRuin),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.buriedTreasure"), BoundingBoxType.BuriedTreasure),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.shipwrecks"), BoundingBoxType.Shipwreck),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Strongholds", BoundingBoxType.Stronghold),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Mineshafts", BoundingBoxType.MineShaft),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Pillager Outposts", BoundingBoxType.PillagerOutpost, false),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.strongholds"), BoundingBoxType.Stronghold),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.mineshafts"), BoundingBoxType.MineShaft),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.pillagerOutposts"), BoundingBoxType.PillagerOutpost, false),
 
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Villages", BoundingBoxType.Village),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "Fortresses", BoundingBoxType.NetherFortress),
-                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, "End Cities", BoundingBoxType.EndCity));
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.villages"), BoundingBoxType.Village),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.fortresses"), BoundingBoxType.NetherFortress),
+                (id, x, y, width) -> new BoundingBoxTypeButton(id, x, y, width, I18n.format("bbor.structures.endCities"), BoundingBoxType.EndCity));
         buildTab(2,
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Village Spheres", ConfigManager.drawVillageSpheres),
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Door Lines", ConfigManager.drawVillageDoors),
-                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, "Golem Spawn", ConfigManager.drawIronGolemSpawnArea),
-
-                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 5, "Dot Size", ConfigManager.villageSphereDotSize),
-                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 5, "Density", ConfigManager.villageSphereDensity)
-                        .addDisplayValue(1, "Fewest")
-                        .addDisplayValue(2, "Fewer")
-                        .addDisplayValue(3, "Normal")
-                        .addDisplayValue(4, "More")
-                        .addDisplayValue(5, "Most"));
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.features.villageSpheres"), ConfigManager.drawVillageSpheres),
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.features.villageSpheres.doorLines"), ConfigManager.drawVillageDoors),
+                (id, x, y, width) -> new BoolSettingButton(id, x, y, width, I18n.format("bbor.features.villageSpheres.golemSpawn"), ConfigManager.drawIronGolemSpawnArea),
+
+                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 5, "bbor.features.villageSpheres.dotSize", ConfigManager.villageSphereDotSize),
+                (id, x, y, width) -> new IntSettingSlider(id, x, y, width, 1, 5, "bbor.features.villageSpheres.density", ConfigManager.villageSphereDensity)
+                        .addDisplayValue(1, I18n.format("bbor.features.villageSpheres.density.fewest"))
+                        .addDisplayValue(2, I18n.format("bbor.features.villageSpheres.density.fewer"))
+                        .addDisplayValue(3, I18n.format("bbor.features.villageSpheres.density.normal"))
+                        .addDisplayValue(4, I18n.format("bbor.features.villageSpheres.density.more"))
+                        .addDisplayValue(5, I18n.format("bbor.features.villageSpheres.density.most")));
     }
 
     private void drawScreen(int top, int bottom) {
diff --git a/src/main/java/com/irtimaled/bbor/client/interop/ModPackFinder.java b/src/main/java/com/irtimaled/bbor/client/interop/ModPackFinder.java
new file mode 100644 (file)
index 0000000..3b737e3
--- /dev/null
@@ -0,0 +1,29 @@
+package com.irtimaled.bbor.client.interop;
+
+import net.minecraft.resources.IPackFinder;
+import net.minecraft.resources.IResourcePack;
+import net.minecraft.resources.ResourcePackInfo;
+import net.minecraft.resources.VanillaPack;
+
+import java.util.Map;
+
+public class ModPackFinder implements IPackFinder {
+    private static final String BBOR = "bbor";
+    private final IResourcePack modPack;
+
+    public ModPackFinder() {
+        modPack = new VanillaPack(BBOR);
+    }
+
+    @Override
+    public <T extends ResourcePackInfo> void addPackInfosToMap(Map<String, T> map, ResourcePackInfo.IFactory<T> factory) {
+        T resourcePackInfo = ResourcePackInfo.createResourcePack(BBOR,
+                true,
+                () -> this.modPack,
+                factory,
+                ResourcePackInfo.Priority.BOTTOM);
+        if (resourcePackInfo != null) {
+            map.put(BBOR, resourcePackInfo);
+        }
+    }
+}
index e3ff7a7bd1309a4e576a88de763f4053fc614d3d..85132e44681e098ae85e9f9ef4f127d76d69a75c 100644 (file)
@@ -5,6 +5,7 @@ import com.irtimaled.bbor.client.interop.SpawningSphereHelper;
 import com.irtimaled.bbor.common.MathHelper;
 import com.irtimaled.bbor.common.models.BoundingBoxSpawningSphere;
 import com.irtimaled.bbor.config.ConfigManager;
+import net.minecraft.client.resources.I18n;
 
 import java.awt.*;
 
@@ -19,7 +20,10 @@ public class SpawningSphereRenderer extends AbstractRenderer<BoundingBoxSpawning
 
         Integer spawnableSpacesCount = boundingBox.getSpawnableSpacesCount();
         if (spawnableSpacesCount != null) {
-            renderText(sphereCenter, "Spawnable", spawnableSpacesCount == 0 ? "None" : String.format("%,d", spawnableSpacesCount));
+            renderText(sphereCenter, I18n.format("bbor.renderer.spawningSphere.spawnable"),
+                    spawnableSpacesCount == 0 ?
+                            I18n.format("bbor.renderer.spawningSphere.none") :
+                            String.format("%,d", spawnableSpacesCount));
         }
 
         renderSphere(sphereCenter, BoundingBoxSpawningSphere.SAFE_RADIUS, Color.GREEN, 5, 5);
index 3bde9db961e68b065e12616b61b22d9a43c8ed3b..b3213f47a9523d8652d5827847ee1bdf58c1ea78 100644 (file)
@@ -1,22 +1,29 @@
 package com.irtimaled.bbor.mixin.client;
 
 import com.irtimaled.bbor.client.ClientProxy;
+import com.irtimaled.bbor.client.interop.ModPackFinder;
 import com.irtimaled.bbor.common.interop.CommonInterop;
 import net.minecraft.client.Minecraft;
 import net.minecraft.client.main.GameConfiguration;
+import net.minecraft.client.resources.ResourcePackInfoClient;
+import net.minecraft.resources.ResourcePackList;
+import org.spongepowered.asm.mixin.Final;
 import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
 import org.spongepowered.asm.mixin.injection.At;
 import org.spongepowered.asm.mixin.injection.Inject;
 import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
 
 @Mixin(Minecraft.class)
 public class MixinMinecraft {
+    @Shadow @Final private ResourcePackList<ResourcePackInfoClient> resourcePackRepository;
     private ClientProxy clientProxy;
 
     @Inject(method = "<init>", at = @At("RETURN"))
     private void constructor(GameConfiguration configuration, CallbackInfo ci) {
         CommonInterop.init();
         clientProxy = new ClientProxy();
+        this.resourcePackRepository.addPackFinder(new ModPackFinder());
     }
 
     @Inject(method = "init", at = @At("RETURN"))
diff --git a/src/main/resources/assets/bbor/lang/en_us.json b/src/main/resources/assets/bbor/lang/en_us.json
new file mode 100644 (file)
index 0000000..6c0f3f8
--- /dev/null
@@ -0,0 +1,71 @@
+{
+  "bbor.key.toggleActive": "Toggle Active",
+
+  "bbor.tabs.general": "General",
+  "bbor.tabs.structures": "Structures",
+  "bbor.tabs.villages": "Villages",
+
+  "bbor.options.active": "Active",
+  "bbor.options.outerBoxOnly": "Outer Box Only",
+  "bbor.options.fill": "Fill",
+
+  "bbor.options.maxY": "Max Y: %s",
+  "bbor.options.maxY.activated": "Activated",
+  "bbor.options.maxY.player": "Player",
+  "bbor.options.maxY.seaLevel": "Sea Level",
+
+  "bbor.options.distance": "Distance: %s",
+  "bbor.options.distance.nearest": "Nearest",
+  "bbor.options.distance.nearer": "Nearer",
+  "bbor.options.distance.normal": "Normal",
+
+  "bbor.features.spawnChunks": "Spawn Chunks",
+  "bbor.features.lazyChunks": "Lazy Chunks",
+  "bbor.features.slimeChunks": "Slime Chunks",
+  "bbor.features.mobSpawners": "Mob Spawners",
+  "bbor.features.mobSpawners.spawnArea": "Spawn Area",
+  "bbor.features.mobSpawners.activationLines": "Activation Lines",
+  "bbor.features.spawningSpheres": "Spawning Spheres",
+  "bbor.features.spawningSpheres.spawnableBlocks": "Spawnable Blocks",
+  "bbor.features.biomeBorders": "Biome Borders",
+  "bbor.features.biomeBorders.onlyThisBiome": "Only This Biome",
+
+  "bbor.structures.desertTemples": "Desert Temples",
+  "bbor.structures.jungleTemples": "Jungle Temples",
+  "bbor.structures.witchHuts": "Witch Huts",
+  "bbor.structures.mansions": "Mansions",
+  "bbor.structures.monuments": "Monuments",
+  "bbor.structures.igloos": "Igloos",
+  "bbor.structures.oceanRuins": "Ocean Ruins",
+  "bbor.structures.buriedTreasure": "Buried Treasure",
+  "bbor.structures.shipwrecks": "Shipwrecks",
+  "bbor.structures.strongholds": "Strongholds",
+  "bbor.structures.mineshafts": "Mineshafts",
+  "bbor.structures.pillagerOutposts": "Pillager Outposts",
+  "bbor.structures.villages": "Villages",
+  "bbor.structures.fortresses": "Fortresses",
+
+  "bbor.features.villageSpheres": "Village Spheres",
+  "bbor.features.villageSpheres.doorLines": "Door Lines",
+  "bbor.features.villageSpheres.golemSpawn": "Golem Spawn",
+  "bbor.features.villageSpheres.dotSize": "Dot Size: %s",
+  "bbor.features.villageSpheres.density": "Density: %s",
+  "bbor.features.villageSpheres.density.fewest": "Fewest",
+  "bbor.features.villageSpheres.density.fewer": "Fewer",
+  "bbor.features.villageSpheres.density.normal": "Normal",
+  "bbor.features.villageSpheres.density.more": "More",
+  "bbor.features.villageSpheres.density.most": "Most",
+
+  "bbor.commands.box.added": "Box added with start [x=%d, y=%d, z=%d] and end [x=%d, y=%d, z=%d]",
+  "bbor.commands.box.cleared.all": "All boxes cleared",
+  "bbor.commands.box.cleared": "Box cleared with start [x=%d, y=%d, z=%d] and end [x=%d, y=%d, z=%d]",
+  "bbor.commands.box.notFound": "No box found with start [x=%d, y=%d, z=%d] and end [x=%d, y=%d, z=%d]",
+
+  "bbor.commands.spawningSphere.set": "Spawning sphere set",
+  "bbor.commands.spawningSphere.notSet": "No spawning sphere set",
+  "bbor.commands.spawningSphere.cleared": "Spawning sphere cleared",
+  "bbor.commands.spawningSphere.calculated": "Calculated %s spawnable spaces",
+
+  "bbor.renderer.spawningSphere.spawnable": "Spawnable:",
+  "bbor.renderer.spawningSphere.none": "None"
+}
\ No newline at end of file