From 623c84f0e15196255cb8abed134d6c1546c53511 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sat, 23 Nov 2019 11:07:55 +0100 Subject: [PATCH] Deprecate server-unsafe UnlocalizedString in favor of ITextComponent A follow-up fix for 874a81fd79a59413286f353f78529c323f8bad50 Closes #127 --- build.properties | 2 +- .../colossalchests/block/ColossalChest.java | 12 +++++------- .../colossalchests/item/ItemUpgradeTool.java | 16 +++++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build.properties b/build.properties index 7dfd09f1..362aec55 100644 --- a/build.properties +++ b/build.properties @@ -3,7 +3,7 @@ minecraft_version=1.14.4 forge_version=28.1.1 mcp_mappings_channel=snapshot mcp_mappings_version=20190719-1.14.3 -cyclopscore_version=1.6.0-1017 +cyclopscore_version=1.6.0-1020 release_type=release fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44 diff --git a/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java b/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java index 4720389c..a090ccd1 100644 --- a/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java +++ b/src/main/java/org/cyclops/colossalchests/block/ColossalChest.java @@ -42,7 +42,6 @@ import org.cyclops.cyclopscore.block.multi.CubeDetector; import org.cyclops.cyclopscore.block.multi.DetectionResult; import org.cyclops.cyclopscore.datastructure.Wrapper; -import org.cyclops.cyclopscore.helper.L10NHelpers; import org.cyclops.cyclopscore.helper.LocationHelpers; import org.cyclops.cyclopscore.helper.MinecraftHelpers; import org.cyclops.cyclopscore.helper.TileHelpers; @@ -217,7 +216,7 @@ public static void addPlayerChatError(ChestMaterial material, World world, Block } } - public static void addPlayerChatError(PlayerEntity player, L10NHelpers.UnlocalizedString unlocalizedError) { + public static void addPlayerChatError(PlayerEntity player, ITextComponent error) { ITextComponent chat = new StringTextComponent(""); ITextComponent prefix = new StringTextComponent("[") .appendSibling(new TranslationTextComponent("multiblock.colossalchests.error.prefix")) @@ -229,7 +228,6 @@ public static void addPlayerChatError(PlayerEntity player, L10NHelpers.Unlocaliz new TranslationTextComponent("multiblock.colossalchests.error.prefix.info") )) ); - ITextComponent error = new StringTextComponent(unlocalizedError.localize()); chat.appendSibling(prefix); chat.appendSibling(error); player.sendMessage(chat); @@ -282,7 +280,7 @@ public MaterialValidationAction() { } @Override - public L10NHelpers.UnlocalizedString onValidate(BlockPos blockPos, BlockState blockState) { + public ITextComponent onValidate(BlockPos blockPos, BlockState blockState) { ChestMaterial material = null; if (blockState.getBlock() instanceof IBlockChestMaterial) { material = ((IBlockChestMaterial) blockState.getBlock()).getMaterial(); @@ -291,10 +289,10 @@ public L10NHelpers.UnlocalizedString onValidate(BlockPos blockPos, BlockState bl requiredMaterial.set(material); return null; } - return requiredMaterial.get() == material ? null : new L10NHelpers.UnlocalizedString( - "multiblock.colossalchests.error.material", new L10NHelpers.UnlocalizedString(material.getUnlocalizedName()), + return requiredMaterial.get() == material ? null : new TranslationTextComponent( + "multiblock.colossalchests.error.material", new TranslationTextComponent(material.getUnlocalizedName()), LocationHelpers.toCompactString(blockPos), - new L10NHelpers.UnlocalizedString(requiredMaterial.get().getUnlocalizedName())); + new TranslationTextComponent(requiredMaterial.get().getUnlocalizedName())); } } } diff --git a/src/main/java/org/cyclops/colossalchests/item/ItemUpgradeTool.java b/src/main/java/org/cyclops/colossalchests/item/ItemUpgradeTool.java index efddf851..b236d095 100644 --- a/src/main/java/org/cyclops/colossalchests/item/ItemUpgradeTool.java +++ b/src/main/java/org/cyclops/colossalchests/item/ItemUpgradeTool.java @@ -15,6 +15,8 @@ import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Vec3d; import net.minecraft.util.math.Vec3i; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.World; import org.apache.commons.lang3.tuple.Pair; import org.cyclops.colossalchests.Advancements; @@ -68,15 +70,15 @@ public ActionResultType onItemUseFirst(ItemStack itemStack, ItemUseContext conte if(context.getWorld().isRemote()) { return ActionResultType.PASS; } - ColossalChest.addPlayerChatError(context.getPlayer(), new L10NHelpers.UnlocalizedString( + ColossalChest.addPlayerChatError(context.getPlayer(), new TranslationTextComponent( "multiblock.colossalchests.error.upgradeLimit")); return ActionResultType.FAIL; } // Loop over the up/downgrade tiers until one works. - L10NHelpers.UnlocalizedString firstError = null; + ITextComponent firstError = null; do { - L10NHelpers.UnlocalizedString error = attemptTransform(context.getWorld(), context.getPos(), context.getPlayer(), tile, newType, tile.getMaterial(), context.getHand()); + ITextComponent error = attemptTransform(context.getWorld(), context.getPos(), context.getPlayer(), tile, newType, tile.getMaterial(), context.getHand()); if (error != null) { if (firstError == null) { firstError = error; @@ -92,7 +94,7 @@ public ActionResultType onItemUseFirst(ItemStack itemStack, ItemUseContext conte return context.getWorld().isRemote() ? ActionResultType.PASS : ActionResultType.SUCCESS; } - protected L10NHelpers.UnlocalizedString attemptTransform(final World world, BlockPos pos, PlayerEntity player, + protected ITextComponent attemptTransform(final World world, BlockPos pos, PlayerEntity player, final TileColossalChest tile, final ChestMaterial newType, final ChestMaterial currentType, Hand hand) { Vec3i size = tile.getSize(); @@ -124,16 +126,16 @@ protected L10NHelpers.UnlocalizedString attemptTransform(final World world, Bloc ItemStack requiredWalls = new ItemStack(newType.getBlockWall(), requiredWallsCount.get()); if (validMaterial == null) { - return new L10NHelpers.UnlocalizedString("multiblock.colossalchests.error.unexpected"); + return new TranslationTextComponent("multiblock.colossalchests.error.unexpected"); } // Check required items in inventory if (!(consumeItems(player, requiredCores, true) && consumeItems(player, requiredInterfaces, true) && consumeItems(player, requiredWalls, true))) { - return new L10NHelpers.UnlocalizedString( + return new TranslationTextComponent( "multiblock.colossalchests.error.upgrade", requiredCores.getCount(), - requiredInterfaces.getCount(), requiredWalls.getCount(), new L10NHelpers.UnlocalizedString(newType.getUnlocalizedName())); + requiredInterfaces.getCount(), requiredWalls.getCount(), new TranslationTextComponent(newType.getUnlocalizedName())); } // Actually consume the items