Add tooltip information for engines

This commit is contained in:
mezz committed 2016-04-28 22:46:19 -07:00
1 parent c95f70a677
commit c4e52f8670
4 files changed
+35 -4

No files matched your search

@@ -18,6 +18,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
import forestry.core.blocks.IBlockWithMeta;
import forestry.core.tiles.TileForestry;
import forestry.core.tiles.TileUtil;
@@ -51,7 +52,7 @@ public class ItemBlockForestry<B extends Block> extends ItemBlock {
}
return block.getUnlocalizedName();
}
@Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, IBlockState newState) {
boolean placed = super.placeBlockAt(stack, player, world, pos, side, hitX, hitY, hitZ, newState);
@@ -11,12 +11,12 @@
package forestry.energy.blocks;
import forestry.core.blocks.BlockRegistry;
import forestry.core.items.ItemBlockForestry;
import forestry.energy.items.ItemEngine;
public class BlockRegistryEnergy extends BlockRegistry {
public final BlockEngine engine;
public BlockRegistryEnergy() {
engine = registerBlock(new BlockEngine(), ItemBlockForestry.class, "engine");
engine = registerBlock(new BlockEngine(), ItemEngine.class, "engine");
}
}
@@ -0,0 +1,30 @@
package forestry.energy.items;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import forestry.core.items.ItemBlockForestry;
import forestry.core.utils.Translator;
import forestry.energy.blocks.BlockEngine;
public class ItemEngine extends ItemBlockForestry<BlockEngine> {
public ItemEngine(Block block) {
super(block);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer playerIn, List<String> tooltip, boolean advanced) {
super.addInformation(stack, playerIn, tooltip, advanced);
String unlocalizedName = getUnlocalizedName(stack);
String tooltipKey = unlocalizedName + ".tooltip";
String tooltipInfo = Translator.translateToLocal(tooltipKey);
Minecraft minecraft = Minecraft.getMinecraft();
List<String> tooltipInfoWrapped = minecraft.fontRendererObj.listFormattedStringToWidth(tooltipInfo, 150);
tooltip.addAll(tooltipInfoWrapped);
}
}