diff --git a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java index cb477aae..61477591 100644 --- a/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java +++ b/src/main/java/cr0s/warpdrive/config/WarpDriveConfig.java @@ -203,6 +203,7 @@ public class WarpDriveConfig { public static EnumTooltipCondition TOOLTIP_ADD_REGISTRY_NAME = EnumTooltipCondition.ADVANCED_TOOLTIPS; public static EnumTooltipCondition TOOLTIP_ADD_ORE_DICTIONARY_NAME = EnumTooltipCondition.ALWAYS; public static EnumTooltipCondition TOOLTIP_ADD_ARMOR_POINTS = EnumTooltipCondition.NEVER; + public static EnumTooltipCondition TOOLTIP_ADD_BLOCK_MATERIAL = EnumTooltipCondition.ADVANCED_TOOLTIPS; public static EnumTooltipCondition TOOLTIP_ADD_BURN_TIME = EnumTooltipCondition.ADVANCED_TOOLTIPS; public static EnumTooltipCondition TOOLTIP_ADD_DURABILITY = EnumTooltipCondition.ALWAYS; public static EnumTooltipCondition TOOLTIP_ADD_ENCHANTABILITY = EnumTooltipCondition.ON_SNEAK; @@ -822,6 +823,8 @@ public class WarpDriveConfig { String.format(commentTooltip, "ore dictionary names")).getString()); TOOLTIP_ADD_ARMOR_POINTS = EnumTooltipCondition.valueOf(config.get("tooltip", "add_armor_points", TOOLTIP_ADD_ARMOR_POINTS.name(), String.format(commentTooltip, "armor points")).getString()); + TOOLTIP_ADD_BLOCK_MATERIAL = EnumTooltipCondition.valueOf(config.get("tooltip", "add_block_material", TOOLTIP_ADD_BLOCK_MATERIAL.name(), + String.format(commentTooltip, "block material")).getString()); TOOLTIP_ADD_BURN_TIME = EnumTooltipCondition.valueOf(config.get("tooltip", "add_burn_time", TOOLTIP_ADD_BURN_TIME.name(), String.format(commentTooltip, "burn time")).getString()); TOOLTIP_ADD_DURABILITY = EnumTooltipCondition.valueOf(config.get("tooltip", "add_durability", TOOLTIP_ADD_DURABILITY.name(), diff --git a/src/main/java/cr0s/warpdrive/event/TooltipHandler.java b/src/main/java/cr0s/warpdrive/event/TooltipHandler.java index 87c7f1f1..0a09f6a8 100644 --- a/src/main/java/cr0s/warpdrive/event/TooltipHandler.java +++ b/src/main/java/cr0s/warpdrive/event/TooltipHandler.java @@ -7,12 +7,14 @@ import cr0s.warpdrive.config.WarpDriveConfig; import javax.annotation.Nonnull; +import java.lang.reflect.Field; import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; import net.minecraft.block.Block; +import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.entity.EntityLivingBase; @@ -205,11 +207,29 @@ public class TooltipHandler { } } - // tool related stats + // material stats final IBlockState blockState = getStateForPlacement(block, null, null, EnumFacing.DOWN, 0.0F, 0.0F, 0.0F, event.getItemStack().getMetadata(), null, EnumHand.MAIN_HAND); + if (WarpDriveConfig.TOOLTIP_ADD_BLOCK_MATERIAL.isEnabled(isSneaking, isCreativeMode)) { + try { + final Material material = blockState.getMaterial(); + String name = material.toString(); + for (final Field field : Material.class.getDeclaredFields()) { + if (field.get(null) == material) { + name = field.getName(); + break; + } + } + Commons.addTooltip(event.getToolTip(), String.format("ยง8Material is %s", + name )); + } catch (final Exception exception) { + // no operation + } + } + + // tool related stats if (WarpDriveConfig.TOOLTIP_ADD_HARVESTING.isEnabled(isSneaking, isCreativeMode)) { try { final String harvestTool = block.getHarvestTool(blockState);