From 134198c948741de3131be17748a36fa54045bb32 Mon Sep 17 00:00:00 2001 From: drcrazy Date: Mon, 14 May 2018 12:24:44 +0300 Subject: [PATCH] Updated i18n usage. --- .../java/techreborn/compat/jei/RecipeUtil.java | 18 ++++++++++-------- .../compat/jei/TechRebornJeiPlugin.java | 8 ++++---- .../AlloySmelterRecipeCategory.java | 5 ++--- .../AssemblingMachineRecipeCategory.java | 5 ++--- .../BlastFurnaceRecipeCategory.java | 14 ++++---------- .../centrifuge/CentrifugeRecipeCategory.java | 5 ++--- .../ChemicalReactorRecipeCategory.java | 6 +++--- .../compressor/CompressorRecipeCategory.java | 5 ++--- .../DistillationTowerRecipeCategory.java | 7 ++++--- .../jei/extractor/ExtractorRecipeCategory.java | 5 ++--- .../FluidReplicatorRecipeCategory.java | 5 ++--- .../FusionReactorRecipeCategory.java | 5 ++--- .../fluid/FluidGeneratorRecipeCategory.java | 5 ++--- .../jei/grinder/GrinderRecipeCategory.java | 5 ++--- .../ImplosionCompressorRecipeCategory.java | 5 ++--- .../IndustrialElectrolyzerRecipeCategory.java | 5 ++--- .../IndustrialGrinderRecipeCategory.java | 9 ++++----- .../IndustrialSawmillRecipeCategory.java | 4 ++-- .../RollingMachineRecipeCategory.java | 5 ++--- .../jei/scrapbox/ScrapboxRecipeCategory.java | 5 ++--- .../VacuumFreezerRecipeCategory.java | 5 ++--- .../compat/theoneprobe/ProbeProvider.java | 7 +++---- .../java/techreborn/items/DynamicCell.java | 6 +++--- .../java/techreborn/tiles/cable/TileCable.java | 9 ++++----- 24 files changed, 69 insertions(+), 89 deletions(-) diff --git a/src/main/java/techreborn/compat/jei/RecipeUtil.java b/src/main/java/techreborn/compat/jei/RecipeUtil.java index e3c1d6c34..4d6f382ad 100644 --- a/src/main/java/techreborn/compat/jei/RecipeUtil.java +++ b/src/main/java/techreborn/compat/jei/RecipeUtil.java @@ -31,16 +31,16 @@ import mezz.jei.api.ingredients.IIngredients; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.translation.I18n; import net.minecraftforge.fluids.FluidStack; import reborncore.common.powerSystem.PowerSystem; +import reborncore.common.util.StringUtils; import javax.annotation.Nonnull; import javax.annotation.Nullable; import java.awt.*; import java.util.List; -@SuppressWarnings("deprecation") + public class RecipeUtil { private static final int color = Color.darkGray.getRGB(); @@ -55,7 +55,8 @@ public class RecipeUtil { int lineSpacing = fontRenderer.FONT_HEIGHT + 1; String startCostEU = PowerSystem.getLocaliszedPower(startCost); - String startCostString = I18n.translateToLocalFormatted("techreborn.jei.recipe.start.cost", startCostEU); + //String startCostString = I18n.translateToLocalFormatted("techreborn.jei.recipe.start.cost", startCostEU); + String startCostString = StringUtils.t("techreborn.jei.recipe.start.cost", startCostEU); fontRenderer.drawString(startCostString, x, y, color); y += lineSpacing; @@ -68,18 +69,19 @@ public class RecipeUtil { FontRenderer fontRenderer = minecraft.fontRenderer; int lineSpacing = fontRenderer.FONT_HEIGHT + 1; - String runningCostString = I18n.translateToLocalFormatted("techreborn.jei.recipe.running.cost",PowerSystem.getDisplayPower().abbreviation.toUpperCase(), PowerSystem.getLocaliszedPowerFormattedNoSuffix(euPerTick)); + String runningCostString = StringUtils.t("techreborn.jei.recipe.running.cost", PowerSystem.getDisplayPower().abbreviation.toUpperCase(), PowerSystem.getLocaliszedPowerFormattedNoSuffix(euPerTick)); + //String runningCostString = I18n.translateToLocalFormatted("techreborn.jei.recipe.running.cost",PowerSystem.getDisplayPower().abbreviation.toUpperCase(), PowerSystem.getLocaliszedPowerFormattedNoSuffix(euPerTick)); fontRenderer.drawString(runningCostString, x, y, color); y += lineSpacing; - String processingTimeString1 = I18n.translateToLocalFormatted("techreborn.jei.recipe.processing.time.1", - tickTime); + // String processingTimeString1 = I18n.translateToLocalFormatted("techreborn.jei.recipe.processing.time.1", tickTime); + String processingTimeString1 = StringUtils.t("techreborn.jei.recipe.processing.time.1", tickTime); fontRenderer.drawString(processingTimeString1, x, y, color); y += lineSpacing; int seconds = tickTime / 20; - String processingTimeString2 = I18n.translateToLocalFormatted("techreborn.jei.recipe.processing.time.2", - seconds); + //String processingTimeString2 = I18n.translateToLocalFormatted("techreborn.jei.recipe.processing.time.2", seconds); + String processingTimeString2 = StringUtils.t("techreborn.jei.recipe.processing.time.2", seconds); fontRenderer.drawString(processingTimeString2, x + 10, y, color); } diff --git a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java index 15b6ef920..95c7c1010 100644 --- a/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java +++ b/src/main/java/techreborn/compat/jei/TechRebornJeiPlugin.java @@ -39,7 +39,6 @@ import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; -import net.minecraft.util.text.translation.I18n; import net.minecraftforge.client.event.GuiScreenEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @@ -47,6 +46,7 @@ import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.input.Mouse; import reborncore.api.recipe.RecipeHandler; +import reborncore.common.util.StringUtils; import techreborn.Core; import techreborn.api.fluidreplicator.FluidReplicatorRecipe; import techreborn.api.fluidreplicator.FluidReplicatorRecipeList; @@ -300,11 +300,11 @@ public class TechRebornJeiPlugin implements IModPlugin { TechRebornJeiPlugin.addDebugRecipes(registry); } - registry.addIngredientInfo(ItemParts.getPartByName("rubberSap"), ItemStack.class, I18n.translateToLocal("techreborn.desc.rubberSap")); + registry.addIngredientInfo(ItemParts.getPartByName("rubberSap"), ItemStack.class, StringUtils.t("techreborn.desc.rubberSap")); if (!BehaviorDispenseScrapbox.dispenseScrapboxes) { - registry.addIngredientInfo(new ItemStack(ModItems.SCRAP_BOX), ItemStack.class, I18n.translateToLocal("techreborn.desc.scrapBoxNoDispenser")); + registry.addIngredientInfo(new ItemStack(ModItems.SCRAP_BOX), ItemStack.class, StringUtils.t("techreborn.desc.scrapBoxNoDispenser")); } else { - registry.addIngredientInfo(new ItemStack(ModItems.SCRAP_BOX), ItemStack.class, I18n.translateToLocal("techreborn.desc.scrapBox")); + registry.addIngredientInfo(new ItemStack(ModItems.SCRAP_BOX), ItemStack.class, StringUtils.t("techreborn.desc.scrapBox")); } //NEW ONES diff --git a/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java b/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java index 5b477ab23..8e9a116d6 100644 --- a/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java +++ b/src/main/java/techreborn/compat/jei/alloySmelter/AlloySmelterRecipeCategory.java @@ -31,14 +31,13 @@ import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.recipe.IRecipeCategory; import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.translation.I18n; +import reborncore.common.util.StringUtils; import techreborn.compat.jei.RecipeCategoryUids; import techreborn.compat.jei.RecipeUtil; import techreborn.lib.ModInfo; import javax.annotation.Nonnull; -@SuppressWarnings("deprecation") public class AlloySmelterRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; @@ -49,7 +48,7 @@ public class AlloySmelterRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; @@ -47,7 +46,7 @@ public class AssemblingMachineRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; @@ -49,7 +48,7 @@ public class BlastFurnaceRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; @@ -48,7 +47,7 @@ public class CentrifugeRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0, 1 }; @@ -49,7 +49,7 @@ public class ChemicalReactorRecipeCategory implements IRecipeCategory { private static final int[] INPUT_SLOTS = { 0 }; private static final int[] OUTPUT_SLOTS = { 1 }; @@ -49,7 +48,7 @@ public class CompressorRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); @@ -53,7 +54,7 @@ public class DistillationTowerRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; @@ -49,7 +48,7 @@ public class ExtractorRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] OUTPUT_TANKS = { 0 }; @@ -55,7 +54,7 @@ public class FluidReplicatorRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); @@ -53,7 +52,7 @@ public class FusionReactorRecipeCategory implements IRecipeCategory { public static ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei_fluid_generator.png"); @@ -53,7 +52,7 @@ public class FluidGeneratorRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; @@ -49,7 +48,7 @@ public class GrinderRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = {0, 1}; @@ -49,7 +48,7 @@ public class ImplosionCompressorRecipeCategory implements IRecipeCategory { private static final int[] INPUT_SLOTS = { 0, 1 }; private static final int[] OUTPUT_SLOTS = { 2, 3, 4, 5 }; @@ -51,7 +50,7 @@ public class IndustrialElectrolyzerRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", @@ -50,8 +49,8 @@ public class IndustrialGrinderRecipeCategory implements IRecipeCategory { private static final int[] INPUT_SLOTS = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; private static final int[] OUTPUT_SLOTS = { 10 }; @@ -51,7 +50,7 @@ public class RollingMachineRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; @@ -49,7 +48,7 @@ public class ScrapboxRecipeCategory implements IRecipeCategory { public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/jei.png"); private static final int[] INPUT_SLOTS = { 0 }; @@ -49,7 +48,7 @@ public class VacuumFreezerRecipeCategory implements IRecipeCategory stacks = Arrays.stream(legacyMachineBase.upgradeInventory.contents).filter(stack -> !stack.isEmpty()).collect(Collectors.toList()); try { methodHandle_addStacks.invoke(probeInfo, world, null, stacks, player.isSneaking()); diff --git a/src/main/java/techreborn/items/DynamicCell.java b/src/main/java/techreborn/items/DynamicCell.java index 52c5be00d..69e2ce69b 100644 --- a/src/main/java/techreborn/items/DynamicCell.java +++ b/src/main/java/techreborn/items/DynamicCell.java @@ -40,12 +40,13 @@ import net.minecraft.util.EnumHand; import net.minecraft.util.NonNullList; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.text.translation.I18n; import net.minecraft.world.World; import net.minecraftforge.common.capabilities.ICapabilityProvider; import net.minecraftforge.fluids.*; import net.minecraftforge.fluids.capability.IFluidHandlerItem; import net.minecraftforge.fluids.capability.templates.FluidHandlerItemStack; +import reborncore.common.util.StringUtils; + import org.apache.commons.lang3.Validate; import techreborn.client.TechRebornCreativeTab; import techreborn.events.TRRecipeHandler; @@ -54,7 +55,6 @@ import techreborn.init.ModItems; /** * Created by modmuss50 on 17/05/2016. */ -@SuppressWarnings("deprecation") public class DynamicCell extends Item { public static final int CAPACITY = Fluid.BUCKET_VOLUME; @@ -164,7 +164,7 @@ public class DynamicCell extends Item { FluidStack fluidStack = getFluidHandler(stack).getFluid(); if (fluidStack == null) return super.getItemStackDisplayName(stack); - return I18n.translateToLocal("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName()); + return StringUtils.t("item.techreborn.cell.fluid.name").replaceAll("\\$fluid\\$", fluidStack.getLocalizedName()); } @Override diff --git a/src/main/java/techreborn/tiles/cable/TileCable.java b/src/main/java/techreborn/tiles/cable/TileCable.java index 7fbd56fd2..e26f86582 100644 --- a/src/main/java/techreborn/tiles/cable/TileCable.java +++ b/src/main/java/techreborn/tiles/cable/TileCable.java @@ -31,7 +31,6 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.EnumFacing; import net.minecraft.util.ITickable; import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.translation.I18n; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; @@ -48,7 +47,7 @@ import java.util.List; /** * Created by modmuss50 on 19/05/2017. */ -@SuppressWarnings("deprecation") + public class TileCable extends TileEntity implements ITickable, IEnergyStorage, IListInfoProvider { public int power = 0; private int transferRate = 0; @@ -248,10 +247,10 @@ public class TileCable extends TileEntity implements ITickable, IEnergyStorage, @Override public void addInfo(List info, boolean isRealTile) { if (isRealTile) { - info.add(TextFormatting.GRAY + I18n.translateToLocal("techreborn.tooltip.transferRate") + ": " + info.add(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": " + TextFormatting.GOLD - + PowerSystem.getLocaliszedPowerFormatted(this.transferRate / RebornCoreConfig.euPerFU) + "/t"); - info.add(TextFormatting.GRAY + I18n.translateToLocal("techreborn.tooltip.tier") + ": " + + PowerSystem.getLocaliszedPowerFormatted(transferRate / RebornCoreConfig.euPerFU) + "/t"); + info.add(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(this.cableType.tier.toString())); } }