From 1567920c8e1b6aa6ccbf136e79de8ded27e3835a Mon Sep 17 00:00:00 2001 From: drcrazy Date: Thu, 21 Feb 2019 01:53:33 +0300 Subject: [PATCH] Updated addInformation method for blocks and items --- src/main/java/techreborn/blocks/BlockAlarm.java | 6 ++++-- .../techreborn/blocks/BlockSupercondensator.java | 11 ++++++++--- .../blocks/generator/BlockFusionCoil.java | 14 +++++++++----- .../generator/BlockMagicEnergyAbsorber.java | 9 +++++++-- .../generator/BlockMagicEnergyConverter.java | 13 +++++++++---- .../items/ItemFrequencyTransmitter.java | 15 +++++++-------- .../items/tool/industrial/ItemNanosaber.java | 11 ++++++----- .../items/tool/industrial/ItemOmniTool.java | 8 ++++++-- 8 files changed, 56 insertions(+), 31 deletions(-) diff --git a/src/main/java/techreborn/blocks/BlockAlarm.java b/src/main/java/techreborn/blocks/BlockAlarm.java index 7ef1f22e9..50d18dbf4 100644 --- a/src/main/java/techreborn/blocks/BlockAlarm.java +++ b/src/main/java/techreborn/blocks/BlockAlarm.java @@ -40,6 +40,8 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.IBlockAccess; import net.minecraft.world.IBlockReader; @@ -183,8 +185,8 @@ public class BlockAlarm extends BaseTileBlock { } @Override - public void addInformation(final ItemStack stack, final World world, final List tooltip, ITooltipFlag flag) { - tooltip.add(TextFormatting.GRAY + I18n.format("techreborn.tooltip.alarm")); + public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(new TextComponentTranslation("techreborn.tooltip.alarm").applyTextStyle(TextFormatting.GRAY)); } } diff --git a/src/main/java/techreborn/blocks/BlockSupercondensator.java b/src/main/java/techreborn/blocks/BlockSupercondensator.java index 549204db9..33c79c8d6 100644 --- a/src/main/java/techreborn/blocks/BlockSupercondensator.java +++ b/src/main/java/techreborn/blocks/BlockSupercondensator.java @@ -27,12 +27,17 @@ package techreborn.blocks; import net.minecraft.block.material.Material; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import reborncore.api.tile.IMachineGuiHandler; import reborncore.common.blocks.BlockMachineBase; import java.util.List; +import javax.annotation.Nullable; + public class BlockSupercondensator extends BlockMachineBase { public BlockSupercondensator(Material material) { super(); @@ -41,9 +46,9 @@ public class BlockSupercondensator extends BlockMachineBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - tooltip.add(TextFormatting.RED + "WIP Coming Soon"); - // TODO + public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); + // TODO // Remember to remove WIP override and imports once complete } diff --git a/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java b/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java index 3819ca046..5c14c5d44 100644 --- a/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java +++ b/src/main/java/techreborn/blocks/generator/BlockFusionCoil.java @@ -36,6 +36,9 @@ import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.SoundCategory; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -77,11 +80,12 @@ public class BlockFusionCoil extends Block { } return false; } - + @OnlyIn(Dist.CLIENT) @Override - public void addInformation(ItemStack stack, @Nullable World player, List tooltip, ITooltipFlag advanced) { - super.addInformation(stack, player, tooltip, advanced); - tooltip.add("Right click Fusion Control computer to auto place"); + public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { + super.addInformation(stack, worldIn, tooltip, flagIn); + //TODO: Translate + tooltip.add(new TextComponentString("Right click Fusion Control computer to auto place")); } -} +} \ No newline at end of file diff --git a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java index 7820b476e..5a50d609a 100644 --- a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java +++ b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyAbsorber.java @@ -26,7 +26,10 @@ package techreborn.blocks.generator; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; @@ -35,6 +38,8 @@ import reborncore.common.blocks.BlockMachineBase; import techreborn.TechReborn; import java.util.List; +import javax.annotation.Nullable; + public class BlockMagicEnergyAbsorber extends BlockMachineBase { public BlockMagicEnergyAbsorber() { @@ -43,8 +48,8 @@ public class BlockMagicEnergyAbsorber extends BlockMachineBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - tooltip.add(TextFormatting.RED + "WIP Coming Soon"); + public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); // TODO // Remember to remove WIP override and imports once complete } diff --git a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java index c25218234..025c12c69 100644 --- a/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java +++ b/src/main/java/techreborn/blocks/generator/BlockMagicEnergyConverter.java @@ -26,7 +26,10 @@ package techreborn.blocks.generator; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import reborncore.api.tile.IMachineGuiHandler; import reborncore.client.models.ModelCompound; @@ -35,6 +38,8 @@ import reborncore.common.blocks.BlockMachineBase; import techreborn.TechReborn; import java.util.List; +import javax.annotation.Nullable; + public class BlockMagicEnergyConverter extends BlockMachineBase { public BlockMagicEnergyConverter() { @@ -43,10 +48,10 @@ public class BlockMagicEnergyConverter extends BlockMachineBase { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - tooltip.add(TextFormatting.RED + "WIP Coming Soon"); - //TODO - //Remember to remove WIP override and imports once complete + public void addInformation(ItemStack stack, @Nullable IBlockReader worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); + // TODO + // Remember to remove WIP override and imports once complete } @Override diff --git a/src/main/java/techreborn/items/ItemFrequencyTransmitter.java b/src/main/java/techreborn/items/ItemFrequencyTransmitter.java index d5361b036..201c3abad 100644 --- a/src/main/java/techreborn/items/ItemFrequencyTransmitter.java +++ b/src/main/java/techreborn/items/ItemFrequencyTransmitter.java @@ -34,6 +34,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; @@ -111,22 +112,20 @@ public class ItemFrequencyTransmitter extends Item { @OnlyIn(Dist.CLIENT) @Override - public void addInformation(ItemStack stack, - @Nullable - World worldIn, List tooltip, ITooltipFlag flagIn) { + public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { if (stack.hasTag() && stack.getTag() != null && stack.getTag().hasKey("x") && stack.getTag().hasKey("y") && stack.getTag().hasKey("z") && stack.getTag().hasKey("dim")) { int x = stack.getTag().getInt("x"); int y = stack.getTag().getInt("y"); int z = stack.getTag().getInt("z"); int dim = stack.getTag().getInt("dim"); - tooltip.add(TextFormatting.GRAY + "X: " + TextFormatting.GOLD + x); - tooltip.add(TextFormatting.GRAY + "Y: " + TextFormatting.GOLD + y); - tooltip.add(TextFormatting.GRAY + "Z: " + TextFormatting.GOLD + z); - tooltip.add(TextFormatting.DARK_GRAY + DimensionManager.getProviderType(dim).getName()); + tooltip.add(new TextComponentString(TextFormatting.GRAY + "X: " + TextFormatting.GOLD + x)); + tooltip.add(new TextComponentString(TextFormatting.GRAY + "Y: " + TextFormatting.GOLD + y)); + tooltip.add(new TextComponentString(TextFormatting.GRAY + "Z: " + TextFormatting.GOLD + z)); + tooltip.add(new TextComponentString(TextFormatting.DARK_GRAY + DimensionManager.getProviderType(dim).getName()); } else { - tooltip.add(TextFormatting.GRAY + I18n.format("techreborn.message.noCoordsSet")); + tooltip.add(new TextComponentString(TextFormatting.GRAY + I18n.format("techreborn.message.noCoordsSet"))); } } diff --git a/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java b/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java index 88fcc703d..028cea7c6 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemNanosaber.java @@ -40,8 +40,11 @@ import net.minecraft.item.ItemStack; import net.minecraft.item.ItemSword; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.*; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextComponentTranslation; import net.minecraft.util.text.TextFormatting; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -228,13 +231,11 @@ public class ItemNanosaber extends ItemSword implements IEnergyItemInfo { @OnlyIn(Dist.CLIENT) @Override - public void addInformation(ItemStack stack, - @Nullable - World worldIn, List tooltip, ITooltipFlag flagIn) { + public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { if (!ItemUtils.isActive(stack)) { - tooltip.add(TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberInactive")); + tooltip.add(new TextComponentTranslation("techreborn.message.nanosaberInactive").applyTextStyle(TextFormatting.GRAY)); } else { - tooltip.add(TextFormatting.GRAY + I18n.format("techreborn.message.nanosaberActive")); + tooltip.add(new TextComponentTranslation("techreborn.message.nanosaberActive").applyTextStyle(TextFormatting.GRAY)); } } diff --git a/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java b/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java index 7987bd78f..1875c7c2e 100644 --- a/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java +++ b/src/main/java/techreborn/items/tool/industrial/ItemOmniTool.java @@ -35,6 +35,8 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.*; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; @@ -133,8 +135,10 @@ public class ItemOmniTool extends ItemPickaxe implements IEnergyItemInfo { } @Override - public void addInformation(ItemStack stack, World world, List tooltip, ITooltipFlag flag) { - tooltip.add(TextFormatting.RED + "WIP Coming Soon"); + public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { + tooltip.add(new TextComponentString("WIP Coming Soon").applyTextStyle(TextFormatting.RED)); + // TODO + // Remember to remove WIP override and imports once complete } @Override