Added block material to tooltip

This commit is contained in:
Unknown 2019-08-07 23:47:14 +02:00 committed by unknown
parent 45df32bab9
commit 187b5476d1
2 changed files with 24 additions and 1 deletions

View file

@ -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(),

View file

@ -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);