Skip to content

Commit

Permalink
#18 add blockpos tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
deirn committed Apr 12, 2021
1 parent 8299045 commit 287fec2
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import net.minecraft.util.Identifier;
import org.apache.commons.lang3.StringEscapeUtils;

public class WailaConfig {

Expand Down Expand Up @@ -309,11 +308,11 @@ public JsonElement serialize(ConfigOverlayColor src, Type typeOfSrc, JsonSeriali

public static class ConfigFormatting {

private String modName = StringEscapeUtils.escapeJava("\u00A79\u00A7o%s");
private String blockName = StringEscapeUtils.escapeJava("\u00a7f%s");
private String fluidName = StringEscapeUtils.escapeJava("\u00a7f%s");
private String entityName = StringEscapeUtils.escapeJava("\u00a7f%s");
private String registryName = StringEscapeUtils.escapeJava("\u00a77[%s]");
private String modName = "\u00A79\u00A7o%s";
private String blockName = "\u00a7f%s";
private String fluidName = "\u00a7f%s";
private String entityName = "\u00a7f%s";
private String registryName = "\u00a77[%s]";

public void setModName(String modName) {
this.modName = modName;
Expand All @@ -336,23 +335,23 @@ public void setRegistryName(String registryName) {
}

public String getModName() {
return StringEscapeUtils.unescapeJava(modName);
return modName;
}

public String getBlockName() {
return StringEscapeUtils.unescapeJava(blockName);
return blockName;
}

public String getFluidName() {
return StringEscapeUtils.unescapeJava(fluidName);
return fluidName;
}

public String getEntityName() {
return StringEscapeUtils.unescapeJava(entityName);
return entityName;
}

public String getRegistryName() {
return StringEscapeUtils.unescapeJava(registryName);
return registryName;
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import net.minecraft.util.Nameable;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;

Expand Down Expand Up @@ -53,6 +54,11 @@ public void appendHead(List<Text> tooltip, IBlockAccessor accessor, IPluginConfi

@Override
public void appendBody(List<Text> tooltip, IBlockAccessor accessor, IPluginConfig config) {
if (config.get(WailaCore.CONFIG_SHOW_POS)) {
BlockPos pos = accessor.getPosition();
tooltip.add(new LiteralText("(" + pos.getX() + ", " + pos.getY() + ", " + pos.getZ() + ")"));
}

if (config.get(WailaCore.CONFIG_SHOW_STATES)) {
BlockState state = accessor.getBlockState();
state.getProperties().forEach(p -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class WailaCore implements IWailaPlugin {
static final Identifier CONFIG_SHOW_REGISTRY = Waila.id("show_registry");
static final Identifier CONFIG_SHOW_ENTITY_HEALTH = Waila.id("show_entity_hp");
static final Identifier CONFIG_SHOW_STATES = Waila.id("show_states");
static final Identifier CONFIG_SHOW_POS = Waila.id("show_pos");

@Override
public void register(IRegistrar registrar) {
Expand All @@ -52,6 +53,7 @@ public void register(IRegistrar registrar) {
registrar.addConfig(CONFIG_SHOW_REGISTRY, false);
registrar.addConfig(CONFIG_SHOW_ENTITY_HEALTH, true);
registrar.addConfig(CONFIG_SHOW_STATES, false);
registrar.addConfig(CONFIG_SHOW_POS, false);

registrar.addRenderer(RENDER_ENTITY_HEALTH, new TooltipRendererHealth());
}
Expand Down
3 changes: 2 additions & 1 deletion common/src/main/resources/assets/waila/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,6 @@
"config.waila.plugin_waila.show_item" : "Show Item",
"config.waila.plugin_waila.show_item_desc" : "Show the item gotten from the block",
"config.waila.plugin_waila.show_entity_hp" : "Show Entity Health",
"config.waila.plugin_waila.show_states" : "Show States"
"config.waila.plugin_waila.show_states" : "Show States",
"config.waila.plugin_waila.show_pos" : "Show Block Position"
}

0 comments on commit 287fec2

Please sign in to comment.