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
15 changes: 10 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
plugins {
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'fabric-loom' version '1.14-SNAPSHOT'
id 'maven-publish'
id 'java'
}

sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

archivesBaseName = project.archives_base_name
base {
archivesName = project.archives_base_name
}
version = project.mod_version
group = project.maven_group

Expand Down Expand Up @@ -78,7 +83,7 @@ java {

jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
rename { "${it}_${project.base.archivesName.get()}"}
}
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx4G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.9
yarn_mappings=1.21.9+build.1
loader_version=0.17.3
minecraft_version=1.21.11
yarn_mappings=1.21.11+build.4
loader_version=0.18.4

# Mod Properties
mod_version = 4.1.1+1.21.9
mod_version = 4.1.1+1.21.11
maven_group = com.minenash
archives_base_name = custom_hud

# Dependencies
#Fabric api
fabric_version=0.134.0+1.21.9
fabric_version=0.141.1+1.21.11
modmenu_version=16.0.0-rc.1
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/minenash/customhud/CustomHud.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ else if (saveDelay == 0) {
ProfileManager.enabled = true;
saveDelay = 100;
}
for (Toggle t : p.toggles.values()) {
}
// Only check toggles for the active profile to avoid consuming key presses
Profile activeProfile = ProfileManager.getActive();
if (activeProfile != null) {
for (Toggle t : activeProfile.toggles.values()) {
boolean wasPressed = t.key.wasPressed();
if (isKeybindPressed(t.modifier) && wasPressed)
t.toggle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.Arm;
import net.minecraft.util.Pair;
import net.minecraft.util.TranslatableOption;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -26,7 +25,7 @@ public class SettingsElement {
public static boolean initialized = false;

//Boolean, Integer, Double
private static final Map<String, SimpleOption<?>> simpleOptions = new HashMap<>();
public static final Map<String, SimpleOption<?>> simpleOptions = new HashMap<>();
private static final Map<String, Integer> staticIntOptions = new HashMap<>();

private static void init() {
Expand Down Expand Up @@ -132,13 +131,23 @@ private static HudElement getSimpleOptionElement(SimpleOption<?> option, Flags f
return new NumberSupplierElement(NumberSupplierElement.of(() -> (Number) option.getValue(), option.getValue() instanceof Integer ? 0 : 1), flags);
if (option.getValue() instanceof String)
return new StringSupplierElement(() -> ((String)option.getValue()).isEmpty() ? "Default" : (String)option.getValue());
if (option.getValue() instanceof TranslatableOption) {
final int falseValue = getFalseValue((TranslatableOption) option.getValue());
if (option.getValue() instanceof ParticlesMode) {
return new SpecialSupplierElement(SpecialSupplierElement.of(
() -> ((TranslatableOption)option.getValue()).getText().getString(),
((TranslatableOption) option.getValue())::getId,
() -> ((TranslatableOption)option.getValue()).getId() != falseValue
));
() -> ((ParticlesMode) option.getValue()).toString().toLowerCase(),
() -> ((ParticlesMode) option.getValue()).ordinal(),
() -> ((ParticlesMode) option.getValue()).ordinal() != 2));
}
if (option.getValue() instanceof ChatVisibility) {
return new SpecialSupplierElement(SpecialSupplierElement.of(
() -> ((ChatVisibility) option.getValue()).toString().toLowerCase(),
() -> ((ChatVisibility) option.getValue()).ordinal(),
() -> ((ChatVisibility) option.getValue()).ordinal() != 2));
}
if (option.getValue() instanceof Arm) {
return new SpecialSupplierElement(SpecialSupplierElement.of(
() -> ((Arm) option.getValue()).toString().toLowerCase(),
() -> ((Arm) option.getValue()).ordinal(),
() -> ((Arm) option.getValue()).ordinal() != 1));
}
if (option.getValue() instanceof NarratorMode)
return new SpecialSupplierElement(SpecialSupplierElement.of(
Expand All @@ -149,13 +158,4 @@ private static HudElement getSimpleOptionElement(SimpleOption<?> option, Flags f
return null;
}

private static int getFalseValue(TranslatableOption option) {
if (option instanceof ParticlesMode || option instanceof ChatVisibility)
return 2;
if (option instanceof Arm)
return 1;
return 0; // GraphicsMode, AoMode, ChunkBuilderMode, CloudRenderMode, AttackIndicator

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ private static double biome(DensityFunction function, MultiNoiseUtil.ParameterRa
public static final Supplier<Number> WORLD_HEIGHT = () -> ComplexData.world.getHeight();
public static final Supplier<Number> WORLD_COORD_SCALE = () -> ComplexData.world.getDimension().coordinateScale();;

public static final Supplier<Number> MOON_PHASE = () -> ComplexData.clientChunk.isEmpty() ? null : client.world.getMoonPhase()+1;
public static final Supplier<Number> MOON_PHASE = () -> ComplexData.clientChunk.isEmpty() ? null : (int)(client.world.getTimeOfDay() / 24000L % 8L) + 1;

public static final Supplier<Number> SPAWN_CHUNKS = () -> {
SpawnHelper.Info info = ComplexData.serverWorld.getChunkManager().getSpawnInfo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@

import com.minenash.customhud.complex.ComplexData;
import com.minenash.customhud.HudElements.interfaces.HudElement;
import com.minenash.customhud.HudElements.SettingsElement;
import com.minenash.customhud.mixin.accessors.GameOptionsAccessor;
import net.fabricmc.fabric.api.renderer.v1.Renderer;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.option.CloudRenderMode;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.GraphicsMode;
import net.minecraft.client.option.SimpleOption;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.Item;
Expand Down Expand Up @@ -76,13 +79,47 @@ private static boolean isFacingEastOrSouth() {
() -> client.player.getOffHandStack().getName().getString().length(),
() -> !client.player.getOffHandStack().isEmpty());

public static final Entry GRAPHICS_MODE = of( () -> client.options.getGraphicsMode().getValue().toString(),
() -> client.options.getGraphicsMode().getValue() == GraphicsMode.FAST ? 0 : (client.options.getGraphicsMode().getValue() == GraphicsMode.FANCY ? 1 : 2),
() -> true);

public static final Entry CLOUDS = of( () -> client.options.getCloudRenderMode().getValue() == CloudRenderMode.OFF ? "off" : (client.options.getCloudRenderMode().getValue() == CloudRenderMode.FAST ? "fast" : "fancy"),
() -> client.options.getCloudRenderMode().getValue() == CloudRenderMode.OFF ? 0 : (client.options.getCloudRenderMode().getValue() == CloudRenderMode.FAST ? 1 : 2),
() -> client.options.getCloudRenderMode().getValue() != CloudRenderMode.OFF);
public static final Entry GRAPHICS_MODE = of(() -> {
if (!SettingsElement.initialized)
return "fancy";
var opt = SettingsElement.simpleOptions.get("graphicsmode");
if (opt == null)
return "fancy";
var value = opt.getValue();
return value instanceof GraphicsMode ? value.toString().toLowerCase() : "fancy";
},
() -> {
if (!SettingsElement.initialized)
return 1;
var opt = SettingsElement.simpleOptions.get("graphicsmode");
if (opt == null)
return 1;
var value = opt.getValue();
if (value instanceof GraphicsMode) {
return ((GraphicsMode) value) == GraphicsMode.FAST ? 0
: (((GraphicsMode) value) == GraphicsMode.FANCY ? 1 : 2);
}
return 1;
},
() -> true);

public static final Entry CLOUDS = of(
() -> {
@SuppressWarnings("unchecked")
var opt = (SimpleOption<CloudRenderMode>) ((GameOptionsAccessor) client.options).getCloudRenderMode();
return opt.getValue() == CloudRenderMode.OFF ? "off"
: (opt.getValue() == CloudRenderMode.FAST ? "fast" : "fancy");
},
() -> {
@SuppressWarnings("unchecked")
var opt = (SimpleOption<CloudRenderMode>) ((GameOptionsAccessor) client.options).getCloudRenderMode();
return opt.getValue() == CloudRenderMode.OFF ? 0 : (opt.getValue() == CloudRenderMode.FAST ? 1 : 2);
},
() -> {
@SuppressWarnings("unchecked")
var opt = (SimpleOption<CloudRenderMode>) ((GameOptionsAccessor) client.options).getCloudRenderMode();
return opt.getValue() != CloudRenderMode.OFF;
});

public static final Entry GAMEMODE = of ( () -> client.interactionManager.getCurrentGameMode().getId(),
() -> client.interactionManager.getCurrentGameMode().getIndex(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class StringSupplierElement implements HudElement {
public static final Supplier<String> BIOME = () -> I18n.translate("biome." + client.world.getBiome(blockPos()).getKey().get().getValue().toString().replace(':', '.'));

private static final String[] moon_phases = new String[]{"full moon", "waning gibbous", "last quarter", "waning crescent", "new moon", "waxing crescent", "first quarter", "waxing gibbous"};
public static final Supplier<String> MOON_PHASE_WORD = () -> ComplexData.clientChunk.isEmpty() ? null : moon_phases[client.world.getMoonPhase()];
public static final Supplier<String> MOON_PHASE_WORD = () -> ComplexData.clientChunk.isEmpty() ? null : moon_phases[(int) (client.world.getTimeOfDay() / 24000L % 8L)];

public static final Supplier<String> TIME_AM_PM = () -> ComplexData.timeOfDay < 12000 ? "am" : "pm";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ public static void update(Profile profile) {

if (profile.enabled.localDifficulty) {
Profilers.get().push("localDifficulty");
localDifficulty = new LocalDifficulty(world.getDifficulty(), world.getTimeOfDay(), serverChunk == null ? 0 : serverChunk.getInhabitedTime(), world.getMoonSize());
localDifficulty = new LocalDifficulty(world.getDifficulty(), world.getTimeOfDay(),
serverChunk == null ? 0 : serverChunk.getInhabitedTime(), world.getTimeOfDay());
Profilers.get().pop();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ private boolean getDebugCrosshairEnable(boolean original) {

@WrapWithCondition(method = "renderCrosshair", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lcom/mojang/blaze3d/pipeline/RenderPipeline;Lnet/minecraft/util/Identifier;IIII)V", ordinal = 0))
private boolean skipNormalCrosshairRendering0(DrawContext instance, RenderPipeline pipeline, Identifier sprite, int x, int y, int width, int height) {
return ProfileManager.getActive() != null && ProfileManager.getActive().crosshair == Crosshairs.NORMAL;
return ProfileManager.getActive() == null || ProfileManager.getActive().crosshair == Crosshairs.NORMAL;
}

}



Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ private static void checkKeybinds(InputUtil.Key key, CallbackInfo ci) {
for (Profile p : ProfileManager.getProfiles()) {
if (p.keyBinding.matchesKey(input))
++p.keyBinding.timesPressed;
for (Toggle t : p.toggles.values()) {
}
Profile activeProfile = ProfileManager.getActive();
if (activeProfile != null) {
for (Toggle t : activeProfile.toggles.values()) {
if (t.key.matchesKey(input))
++t.key.timesPressed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@Mixin(PlayerEntity.class)
public class PlayerEntityMixin {

@Inject(method = "attack", at = @At(value = "INVOKE", target = "Lnet/minecraft/entity/player/PlayerEntity;resetLastAttackedTicks()V"))
@Inject(method = "attack", at = @At("HEAD"))
private void logAttack(Entity target, CallbackInfo ci) {
if (((Object)this) == MinecraftClient.getInstance().player && ComplexData.targetEntityHitPos != null) {
ComplexData.lastHitEntity = target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ public interface GameOptionsAccessor {

@Accessor Map<SoundCategory, SimpleOption<Double>> getSoundVolumeLevels();

@Accessor("cloudRenderMode")
SimpleOption<?> getCloudRenderMode();

}