Fixed block information tooltips on pure items

This commit is contained in:
LemADEC 2016-01-13 01:08:52 +01:00
parent 6ddda39d9e
commit 40c69679a9

View file

@ -1,6 +1,7 @@
package cr0s.warpdrive.event;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
@ -19,23 +20,25 @@ public class ClientHandler {
}
if (WarpDrive.isDev) {// disabled in production
Block block = Block.getBlockFromItem(event.itemStack.getItem());
try {
String harvestTool = block.getHarvestTool(event.itemStack.getItemDamage());
if (harvestTool != null) {
event.toolTip.add("Harvest with " + harvestTool + " (" + block.getHarvestLevel(event.itemStack.getItemDamage()) + ")");
if (block != Blocks.air) {
try {
String harvestTool = block.getHarvestTool(event.itemStack.getItemDamage());
if (harvestTool != null) {
event.toolTip.add("Harvest with " + harvestTool + " (" + block.getHarvestLevel(event.itemStack.getItemDamage()) + ")");
}
} catch(Exception exception) {
// no operation
}
} catch(Exception exception) {
// no operation
event.toolTip.add("Light opacity is " + block.getLightOpacity());
try {
event.toolTip.add("Hardness is " + (float)WarpDrive.fieldBlockHardness.get(block));
} catch(Exception exception) {
// no operation
}
event.toolTip.add("Explosion resistance is " + block.getExplosionResistance(null));
}
event.toolTip.add("Light opacity is " + block.getLightOpacity());
try {
event.toolTip.add("Hardness is " + (float)WarpDrive.fieldBlockHardness.get(block));
} catch(Exception exception) {
// no operation
}
event.toolTip.add("Explosion resistance is " + block.getExplosionResistance(null));
}
}
}