Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@
import java.io.IOException;

public record EmiOresClientConfig(
boolean addBiomesToIndex
boolean addBiomesToIndex,
boolean showHeightValuesForCurrentDimensionByDefault
) {
public static Codec<EmiOresClientConfig> CODEC = RecordCodecBuilder.create(instance -> instance.group(
Codec.BOOL.fieldOf("add_biomes_to_index").forGetter(EmiOresClientConfig::addBiomesToIndex)
Codec.BOOL.fieldOf("add_biomes_to_index").forGetter(EmiOresClientConfig::addBiomesToIndex),
Codec.BOOL.fieldOf("show_height_values_for_current_dimension_by_default").forGetter(EmiOresClientConfig::showHeightValuesForCurrentDimensionByDefault)
).apply(instance, EmiOresClientConfig::new));

private static final EmiOresClientConfig DEFAULT = new EmiOresClientConfig(
true
true,
false
);
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

import cc.abbie.emi_ores.EmiOres;
import cc.abbie.emi_ores.client.FeaturesReciever;
import cc.abbie.emi_ores.client.config.EmiOresClientConfig;
import cc.abbie.emi_ores.mixin.accessor.TrapezoidHeightAccessor;
import cc.abbie.emi_ores.mixin.accessor.UniformHeightAccessor;
import dev.emi.emi.api.recipe.EmiRecipe;
import dev.emi.emi.api.widget.TextWidget;
import dev.emi.emi.api.widget.WidgetHolder;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.Registry;
import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
Expand All @@ -35,21 +37,31 @@ protected static Component anchorText(VerticalAnchor anchor) {
s = String.valueOf(absolute.y());
} else if (anchor instanceof VerticalAnchor.AboveBottom aboveBottom) {
int offset = aboveBottom.offset();
if (offset == 0) {
s = "bot";
} else if (offset > 0) {
s = "bot+" + offset;
if (useCurrentDimension()) {
int height = Minecraft.getInstance().level.getMinBuildHeight() + offset;
s = String.valueOf(height);
} else {
s = "bot" + offset;
if (offset == 0) {
s = "bot";
} else if (offset > 0) {
s = "bot+" + offset;
} else {
s = "bot" + offset;
}
}
} else if (anchor instanceof VerticalAnchor.BelowTop belowTop) {
int offset = -belowTop.offset();
if (offset == 0) {
s = "top";
} else if (offset > 0) {
s = "top+" + offset;
if (useCurrentDimension()) {
int height = Minecraft.getInstance().level.getMaxBuildHeight() + offset;
s = String.valueOf(height);
} else {
s = "top" + offset;
if (offset == 0) {
s = "top";
} else if (offset > 0) {
s = "top+" + offset;
} else {
s = "top" + offset;
}
}
} else {
throw new RuntimeException();
Expand All @@ -66,21 +78,31 @@ private static MutableComponent anchorTextLongInner(VerticalAnchor anchor) {
return Component.literal(String.valueOf(absolute.y()));
} else if (anchor instanceof VerticalAnchor.AboveBottom aboveBottom) {
int offset = aboveBottom.offset();
if (offset == 0) {
return Component.translatable("emi_ores.distribution.anchor.bottom");
} else if (offset > 0) {
return Component.translatable("emi_ores.distribution.anchor.above_bottom", offset);
if (useCurrentDimension()) {
int height = Minecraft.getInstance().level.getMinBuildHeight() + offset;
return Component.literal(String.valueOf(height));
} else {
return Component.translatable("emi_ores.distribution.anchor.below_bottom", -offset);
if (offset == 0) {
return Component.translatable("emi_ores.distribution.anchor.bottom");
} else if (offset > 0) {
return Component.translatable("emi_ores.distribution.anchor.above_bottom", offset);
} else {
return Component.translatable("emi_ores.distribution.anchor.below_bottom", -offset);
}
}
} else if (anchor instanceof VerticalAnchor.BelowTop belowTop) {
int offset = -belowTop.offset();
if (offset == 0) {
return Component.translatable("emi_ores.distribution.anchor.top");
} else if (offset > 0) {
return Component.translatable("emi_ores.distribution.anchor.above_top", offset);
if (useCurrentDimension()) {
int height = Minecraft.getInstance().level.getMaxBuildHeight() + offset;
return Component.literal(String.valueOf(height));
} else {
return Component.translatable("emi_ores.distribution.anchor.below_top", -offset);
if (offset == 0) {
return Component.translatable("emi_ores.distribution.anchor.top");
} else if (offset > 0) {
return Component.translatable("emi_ores.distribution.anchor.above_top", offset);
} else {
return Component.translatable("emi_ores.distribution.anchor.below_top", -offset);
}
}
} else {
throw new RuntimeException();
Expand Down Expand Up @@ -169,6 +191,12 @@ protected static List<Component> getDistributionGraphTooltip(HeightProviderType
tooltip.add(Component.translatable("emi_ores.distribution.middle_range", anchorTextLong(midLow), anchorTextLong(midHigh)).withStyle(ChatFormatting.GRAY));
}
}
if (useCurrentDimension()) {
tooltip.add(Component.translatable("emi_ores.distribution.dimension", Minecraft.getInstance().level.dimension().location()).withStyle(ChatFormatting.GRAY));
tooltip.add(Component.translatable("emi_ores.distribution.shift.relative").withStyle(ChatFormatting.GRAY));
} else {
tooltip.add(Component.translatable("emi_ores.distribution.shift.dimension").withStyle(ChatFormatting.GRAY));
}
return tooltip;
}

Expand All @@ -188,6 +216,10 @@ protected static Component getVeinFreqComponent(int countMin, int countMax, int
return veinFreq;
}

protected static boolean useCurrentDimension() {
return Screen.hasShiftDown() != EmiOresClientConfig.INSTANCE.showHeightValuesForCurrentDimensionByDefault();
}

protected enum HeightProviderType {
UNIFORM(0, Component.translatable("emi_ores.distribution.uniform").withStyle(ChatFormatting.BLUE)),
TRIANGULAR(16, Component.translatable("emi_ores.distribution.triangle").withStyle(ChatFormatting.GREEN)),
Expand Down
3 changes: 3 additions & 0 deletions xplat/src/main/resources/assets/emi_ores/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
"emi_ores.distribution.anchor.below_top": "%s below top",
"emi_ores.distribution.middle": "Most common at %s",
"emi_ores.distribution.middle_range": "Most common from %s to %s",
"emi_ores.distribution.dimension": "Applies to current dimension only (%s), which may not contain this feature",
"emi_ores.distribution.shift.dimension": "Hold SHIFT for current dimension's height values",
"emi_ores.distribution.shift.relative": "Hold SHIFT for relative height values",

"tag.c.aquatic": "Aquatic",
"tag.c.aquatic_icy": "Icy Aquatic",
Expand Down