Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions src/main/java/com/gtnewhorizons/wdmla/config/General.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class General {

public static TextColor textColor = new TextColor();

public static ModName modName = new ModName();

public static ProgressColor progressColor = new ProgressColor();

public static BreakProgress breakProgress = new BreakProgress();
Expand Down Expand Up @@ -53,6 +55,12 @@ public class General {
@Config.RangeInt(min = 1, max = 10000)
public static int maxNameLengthPixel;

@Config.LangKey("option.wdmla.general.mobhudrange")
@Config.DefaultInt(64)
@Config.RangeInt(min = 1, max = 256)
@Config.Comment("Maximum distance in blocks at which entities can show WDMla HUD. Only affects entities, not blocks.")
public static int mobHudRange;

@Config.LangKey("option.wdmla.general.align.icon.right.top")
@Config.DefaultBoolean(true)
@Config.Comment("Always put harvest / interaction icons at the right top corner of default block info")
Expand Down Expand Up @@ -92,9 +100,45 @@ public static class TextColor {
@Config.DefaultInt(ColorPalette.FAILURE)
public int failure;

@Config.LangKey("option.wdmla.general.textcolor.modname")
}

@Config.Comment("Mod name display settings.")
@Config.LangKey("option.wdmla.modname.category")
public static class ModName {

@Config.LangKey("option.wdmla.modname.hud.show")
@Config.DefaultBoolean(true)
@Config.Comment("Show mod names in the HUD")
public boolean hudShow;

@Config.LangKey("option.wdmla.modname.hud.italic")
@Config.DefaultBoolean(true)
@Config.Comment("Render mod names in italics in the HUD")
public boolean hudItalic;

@Config.LangKey("option.wdmla.modname.hud.color")
@Config.DefaultInt(ColorPalette.MOD_NAME)
public int modName;
public int hudColor;

@Config.LangKey("option.wdmla.modname.hud.color.override")
@Config.DefaultString("")
@Config.Comment("Override HUD mod name color. Supports hex (#RRGGBB, 0xRRGGBB) or names like RED, BLUE, GRAY")
public String hudColorOverride;

@Config.LangKey("option.wdmla.modname.inventory.show")
@Config.DefaultBoolean(true)
@Config.Comment("Show mod names in inventory tooltips")
public boolean inventoryShow;

@Config.LangKey("option.wdmla.modname.inventory.italic")
@Config.DefaultBoolean(true)
@Config.Comment("Render mod names in italics in inventory tooltips")
public boolean inventoryItalic;

@Config.LangKey("option.wdmla.modname.inventory.color.override")
@Config.DefaultString("")
@Config.Comment("Override inventory mod name color. Supports hex (#RRGGBB, 0xRRGGBB) or names like RED, BLUE, GRAY")
public String inventoryColorOverride;
}

@Config.Comment("The colors used in progress bar. \n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public static class DefaultEntity {
@Config.DefaultFloat(1.2f)
@Config.RangeFloat(min = 0.1f, max = 100f)
public float iconDefaultScale;

@Config.LangKey("option.wdmla.core.show.hptext")
@Config.DefaultBoolean(true)
public boolean showHPText;
}

public static enum fancyRendererMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private void reloadTheme() {
General.textColor.warning,
General.textColor.danger,
General.textColor.failure,
General.textColor.modName);
General.modName.hudColor);
}

public <T extends Enum<T>> T loadEnum(String category, String name, T defaultValue, String comment) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.gtnewhorizons.wdmla.example;

import static mcp.mobius.waila.api.SpecialChars.*;

import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
Expand All @@ -11,8 +9,8 @@
import com.gtnewhorizons.wdmla.api.accessor.BlockAccessor;
import com.gtnewhorizons.wdmla.api.provider.IBlockComponentProvider;
import com.gtnewhorizons.wdmla.api.ui.ITooltip;
import com.gtnewhorizons.wdmla.config.General;
import com.gtnewhorizons.wdmla.impl.ui.ThemeHelper;
import com.gtnewhorizons.wdmla.impl.ui.component.TextComponent;

public enum ExampleHeaderProvider implements IBlockComponentProvider {

Expand All @@ -32,8 +30,10 @@ public int getDefaultPriority() {
public void appendTooltip(ITooltip tooltip, BlockAccessor accessor) {
ThemeHelper.INSTANCE.overrideTooltipIcon(tooltip, new ItemStack(Blocks.lit_furnace), true);
ThemeHelper.INSTANCE.overrideTooltipTitle(tooltip, "Furnace");
tooltip.replaceChildWithTag(
Identifiers.MOD_NAME,
new TextComponent(BLUE + ITALIC + "WDMla").tag(Identifiers.MOD_NAME));
if (General.modName.hudShow) {
tooltip.replaceChildWithTag(
Identifiers.MOD_NAME,
ThemeHelper.INSTANCE.modName("WDMla").tag(Identifiers.MOD_NAME));
}
}
}
18 changes: 15 additions & 3 deletions src/main/java/com/gtnewhorizons/wdmla/impl/ui/ThemeHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.gtnewhorizons.wdmla.impl.ui.style.TextStyle;
import com.gtnewhorizons.wdmla.overlay.WDMlaUIIcons;
import com.gtnewhorizons.wdmla.plugin.vanilla.VanillaIdentifiers;
import com.gtnewhorizons.wdmla.util.Color;
import com.gtnewhorizons.wdmla.util.FormatUtil;

import mcp.mobius.waila.overlay.DisplayUtil;
Expand Down Expand Up @@ -110,9 +111,7 @@ public void overrideTooltipModName(ITooltip root, ItemStack newItemStack) {
}

public void overrideTooltipModName(ITooltip root, String newName) {
Theme theme = General.currentTheme.get();
IComponent replacedModName = new TextComponent(ITALIC + newName)
.style(new TextStyle().color(theme.textColor(MessageType.MOD_NAME))).tag(Identifiers.MOD_NAME);
IComponent replacedModName = modName(newName).tag(Identifiers.MOD_NAME);
root.replaceChildWithTag(Identifiers.MOD_NAME, replacedModName);
}

Expand All @@ -122,6 +121,19 @@ public void overrideTooltipHeader(ITooltip root, ItemStack newItemStack) {
overrideTooltipModName(root, newItemStack);
}

public IComponent modName(String modName) {
String content = modName == null ? "" : modName;
if (General.modName.hudItalic && !content.isEmpty()) {
content = ITALIC + content;
}
return new TextComponent(content).style(new TextStyle().color(resolveModNameColor()));
}

private int resolveModNameColor() {
int fallback = General.currentTheme.get().textColor(MessageType.MOD_NAME);
return Color.parseColor(General.modName.hudColorOverride, fallback);
}

public IComponent info(String content) {
return color(content, MessageType.INFO);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
import com.gtnewhorizons.wdmla.overlay.GuiBlockDraw;

import mcp.mobius.waila.overlay.OverlayConfig;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

import com.gtnewhorizons.wdmla.overlay.GuiDraw;

public class BlockDrawable implements IDrawable {

Expand All @@ -32,7 +38,7 @@ public void draw(IArea area) {
rotationPitch += (Minecraft.getMinecraft().theWorld.getTotalWorldTime() - lastTime)
* PluginsConfig.core.defaultBlock.rendererRotationSpeed;
// custom viewport is unaffected by GLScalef
GuiBlockDraw.drawWorldBlock(
boolean rendered = GuiBlockDraw.drawWorldBlock(
(int) ((area.getX() - area.getW() * (SIZE_MULTIPLIER - 1) / 2) * OverlayConfig.scale),
(int) ((area.getY() - area.getH() * (SIZE_MULTIPLIER - 1) / 2) * OverlayConfig.scale),
(int) (area.getW() * OverlayConfig.scale * SIZE_MULTIPLIER),
Expand All @@ -42,6 +48,26 @@ public void draw(IArea area) {
blockZ,
30f,
rotationPitch);

if (!rendered) {
// If the fancy world-block preview produced no geometry/TESR, fall back to the item icon.
Minecraft mc = Minecraft.getMinecraft();
Block b = mc.theWorld.getBlock(blockX, blockY, blockZ);
if (b == null) b = Blocks.air;
int meta = mc.theWorld.getBlockMetadata(blockX, blockY, blockZ);
Item it = Item.getItemFromBlock(b);
ItemStack stack = null;
if (it != null) {
try {
int dmg = b.damageDropped(meta);
stack = new ItemStack(it, 1, dmg);
} catch (Throwable t) {
stack = new ItemStack(it, 1, meta);
}
}
if (stack == null) stack = new ItemStack(Blocks.air);
GuiDraw.renderStack(area, stack, false, null);
}
lastTime = Minecraft.getMinecraft().theWorld.getTotalWorldTime();
}
}
}
Loading