Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit d24d563

Browse files
committed
add HitColor option, allow Snap Perspective mode
1 parent 2921809 commit d24d563

File tree

11 files changed

+161
-25
lines changed

11 files changed

+161
-25
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,7 @@
7676
- since this is a critical fix, this will also be released for 1.19.2
7777
- add 'Snap-Perspective' mode to Freelook
7878

79+
### 2.2.8
80+
81+
- HitColor option
82+
- Allow Snap Perspective mode to be used on servers where Freelook is disallowed

build.gradle

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ dependencies {
3636
mappings "org.quiltmc:quilt-mappings:${minecraft_version}+build.${quilt_mappings}:intermediary-v2"
3737

3838
modImplementation "org.quiltmc:quilt-loader:${project.loader_version}"
39-
//modImplementation "org.quiltmc.quilted-fabric-api:quilted-fabric-api:${quilted_fabric_api_version}"
40-
41-
//modImplementation "org.quiltmc:qsl:${qsl_version}+${minecraft_version}"
4239

4340
modImplementation "org.quiltmc.qsl.core:resource_loader:${qsl_version}+${minecraft_version}"
4441

@@ -71,8 +68,6 @@ processResources {
7168

7269
tasks.withType(JavaCompile).configureEach {
7370
it.options.encoding = "UTF-8"
74-
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
75-
it.options.release = 17
7671
}
7772

7873
java {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ quilt_mappings = 1
88
loader_version = 0.18.1-beta.21
99

1010
# Quilted Fabric API
11-
qsl_version = 4.0.0-beta.1
11+
qsl_version = 4.0.0-beta.2
1212

1313
# AxolotlClientConfig
1414
config_version = 1.0.15

src/main/java/io/github/axolotlclient/config/AxolotlClientConfig.java

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,19 @@
2222

2323
package io.github.axolotlclient.config;
2424

25+
import com.mojang.blaze3d.systems.RenderSystem;
26+
import com.mojang.blaze3d.texture.NativeImage;
2527
import io.github.axolotlclient.AxolotlClient;
2628
import io.github.axolotlclient.AxolotlclientConfig.AxolotlClientConfigConfig;
2729
import io.github.axolotlclient.AxolotlclientConfig.Color;
2830
import io.github.axolotlclient.AxolotlclientConfig.ConfigHolder;
2931
import io.github.axolotlclient.AxolotlclientConfig.options.*;
3032
import io.github.axolotlclient.NetworkHelper;
3133
import io.github.axolotlclient.config.screen.CreditsScreen;
34+
import io.github.axolotlclient.mixin.OverlayTextureAccessor;
3235
import lombok.Getter;
3336
import net.minecraft.client.MinecraftClient;
37+
import net.minecraft.client.texture.NativeImageBackedTexture;
3438

3539
import java.util.ArrayList;
3640
import java.util.List;
@@ -59,6 +63,37 @@ public class AxolotlClientConfig extends ConfigHolder {
5963
public final BooleanOption fullBright = new BooleanOption("fullBright", false);
6064
public final BooleanOption lowFire = new BooleanOption("lowFire", false);
6165
public final BooleanOption lowShield = new BooleanOption("lowShield", false);
66+
public final ColorOption hitColor = new ColorOption("hitColor",
67+
value -> {
68+
try { // needed because apparently someone created a bug that makes this be called when the config is loaded. Will be fixed with the next release.
69+
NativeImageBackedTexture texture = ((OverlayTextureAccessor) MinecraftClient.getInstance().gameRenderer.getOverlayTexture()).getTexture();
70+
NativeImage nativeImage = texture.getImage();
71+
if (nativeImage != null) {
72+
int color = 255-value.getAlpha();
73+
color = (color << 8) + value.getBlue();
74+
color = (color << 8) + value.getGreen();
75+
color = (color << 8) + value.getRed();
76+
77+
for (int i = 0; i < 16; ++i) {
78+
for (int j = 0; j < 16; ++j) {
79+
if (i < 8) {
80+
nativeImage.setPixelColor(j, i, color);
81+
} else {
82+
int k = (int) ((1.0F - (float) j / 15.0F * 0.75F) * 255.0F);
83+
nativeImage.setPixelColor(j, i, k << 24 | 16777215);
84+
}
85+
}
86+
}
87+
88+
RenderSystem.activeTexture(33985);
89+
texture.bindTexture();
90+
nativeImage.upload(0, 0, 0, 0, 0,
91+
nativeImage.getWidth(), nativeImage.getHeight(), false, true, false, false);
92+
RenderSystem.activeTexture(33984);
93+
}
94+
} catch (Exception ignored){}
95+
},
96+
new Color(255, 0, 0, 77));
6297

6398
public final ColorOption loadingScreenColor = new ColorOption("loadingBgColor", new Color(239, 50, 61, 255));
6499
public final BooleanOption nightMode = new BooleanOption("nightMode", false);
@@ -137,13 +172,14 @@ public void init(){
137172
AxolotlClientConfigConfig.searchSortOrder);
138173
general.addSubCategory(searchFilters);
139174

140-
rendering.add(customSky);
141-
rendering.add(showSunMoon);
142-
rendering.add(AxolotlClientConfigConfig.chromaSpeed);
143-
rendering.add(dynamicFOV);
144-
rendering.add(fullBright);
145-
rendering.add(lowFire);
146-
rendering.add(lowShield);
175+
rendering.add(customSky,
176+
showSunMoon,
177+
AxolotlClientConfigConfig.chromaSpeed,
178+
dynamicFOV,
179+
fullBright,
180+
lowFire,
181+
lowShield,
182+
hitColor);
147183

148184
timeChanger.add(timeChangerEnabled);
149185
timeChanger.add(customTime);

src/main/java/io/github/axolotlclient/mixin/LivingEntityRendererMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected LivingEntityRendererMixin(EntityRendererFactory.Context ctx) {
4444
super(ctx);
4545
}
4646

47-
@Inject(method = "hasLabel*", at = @At("HEAD"), cancellable = true)
47+
@Inject(method = "hasLabel(Lnet/minecraft/entity/LivingEntity;)Z", at = @At("HEAD"), cancellable = true)
4848
private void showOwnNametag(T livingEntity, CallbackInfoReturnable<Boolean> cir) {
4949
if (AxolotlClient.CONFIG.showOwnNametag.get()
5050
&& livingEntity.getId() == MinecraftClient.getInstance().player.getId()
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright © 2021-2022 moehreag <[email protected]> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.mixin;
24+
25+
import net.minecraft.client.render.OverlayTexture;
26+
import net.minecraft.client.texture.NativeImageBackedTexture;
27+
import org.spongepowered.asm.mixin.Mixin;
28+
import org.spongepowered.asm.mixin.gen.Accessor;
29+
30+
@Mixin(OverlayTexture.class)
31+
public interface OverlayTextureAccessor {
32+
33+
@Accessor
34+
NativeImageBackedTexture getTexture();
35+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright © 2021-2022 moehreag <[email protected]> & Contributors
3+
*
4+
* This file is part of AxolotlClient.
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU Lesser General Public
8+
* License as published by the Free Software Foundation; either
9+
* version 3 of the License, or (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+
* Lesser General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU Lesser General Public License
17+
* along with this program; if not, write to the Free Software Foundation,
18+
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19+
*
20+
* For more information, see the LICENSE file.
21+
*/
22+
23+
package io.github.axolotlclient.mixin;
24+
25+
import io.github.axolotlclient.AxolotlClient;
26+
import io.github.axolotlclient.AxolotlclientConfig.Color;
27+
import net.minecraft.client.render.OverlayTexture;
28+
import org.spongepowered.asm.mixin.Mixin;
29+
import org.spongepowered.asm.mixin.injection.Constant;
30+
import org.spongepowered.asm.mixin.injection.ModifyConstant;
31+
32+
@Mixin(OverlayTexture.class)
33+
public abstract class OverlayTextureMixin {
34+
35+
@ModifyConstant(method = "<init>",constant = @Constant(intValue = -1308622593))
36+
private int customHitColor(int constant){
37+
38+
Color c = AxolotlClient.CONFIG.hitColor.get();
39+
int color = 255-c.getAlpha();
40+
color = (color << 8) + c.getBlue();
41+
color = (color << 8) + c.getGreen();
42+
color = (color << 8) + c.getRed();
43+
return color;
44+
}
45+
}

src/main/java/io/github/axolotlclient/modules/freelook/Freelook.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import io.github.axolotlclient.AxolotlclientConfig.options.KeyBindOption;
3030
import io.github.axolotlclient.AxolotlclientConfig.options.OptionCategory;
3131
import io.github.axolotlclient.modules.AbstractModule;
32+
import io.github.axolotlclient.util.FeatureDisabler;
3233
import net.minecraft.client.MinecraftClient;
3334
import net.minecraft.client.option.KeyBind;
3435
import net.minecraft.client.option.Perspective;
@@ -47,7 +48,10 @@ public class Freelook extends AbstractModule {
4748
private final OptionCategory category = new OptionCategory("freelook");
4849
public final BooleanOption enabled = new BooleanOption("enabled", false);
4950
private final KeyBindOption keyOption = new KeyBindOption("key.freelook", KEY = new KeyBind("key.freelook", InputUtil.KEY_V_CODE, "category.axolotlclient"), (key)->{});
50-
private final EnumOption mode = new EnumOption("mode", new String[]{"snap_perspective", "freelook"}, "freelook");
51+
private final EnumOption mode = new EnumOption("mode",
52+
value -> FeatureDisabler.update(),
53+
new String[]{"snap_perspective", "freelook"},
54+
"freelook");
5155
private final EnumOption perspective = new EnumOption("perspective", Perspective.values(),
5256
Perspective.THIRD_PERSON_BACK.toString());
5357
private final BooleanOption invert = new BooleanOption("invert", false);
@@ -156,4 +160,8 @@ public float pitch(float defaultValue) {
156160
private void setPerspective(Perspective perspective) {
157161
MinecraftClient.getInstance().options.setPerspective(perspective);
158162
}
163+
164+
public boolean needsDisabling(){
165+
return mode.get().equals("freelook");
166+
}
159167
}

src/main/java/io/github/axolotlclient/util/FeatureDisabler.java

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,36 +25,40 @@
2525
import io.github.axolotlclient.AxolotlClient;
2626
import io.github.axolotlclient.AxolotlclientConfig.options.BooleanOption;
2727
import io.github.axolotlclient.modules.freelook.Freelook;
28-
import net.minecraft.client.network.ServerInfo;
2928

3029
import java.util.HashMap;
3130
import java.util.Locale;
31+
import java.util.function.Supplier;
3232

3333
public class FeatureDisabler {
3434

3535
private static final HashMap<BooleanOption, String[]> disabledServers = new HashMap<>();
36+
private static final HashMap<BooleanOption, Supplier<Boolean>> conditions = new HashMap<>();
37+
38+
private static final Supplier<Boolean> NONE = ()-> true;
39+
40+
private static String currentAdress;
3641

3742
public static void init() {
38-
setServers(AxolotlClient.CONFIG.fullBright, "gommehd");
39-
setServers(AxolotlClient.CONFIG.timeChangerEnabled, "gommehd");
40-
setServers(Freelook.getInstance().enabled, "hypixel", "mineplex", "gommehd", "nucleoid");
43+
setServers(AxolotlClient.CONFIG.fullBright, NONE, "gommehd");
44+
setServers(AxolotlClient.CONFIG.timeChangerEnabled, NONE, "gommehd");
45+
setServers(Freelook.getInstance().enabled, () -> Freelook.getInstance().needsDisabling(), "hypixel", "mineplex", "gommehd", "nucleoid");
4146
}
4247

4348
public static void onServerJoin(String address) {
44-
disabledServers.forEach((option, strings) -> disableOption(option, strings, address));
49+
currentAdress = address;
50+
update();
4551
}
4652

4753
public static void clear() {
48-
disabledServers.forEach((option, strings) -> {
49-
option.setForceOff(false, "ban_reason");
50-
});
54+
disabledServers.forEach((option, strings) -> option.setForceOff(false, "ban_reason"));
5155
}
5256

5357
private static void disableOption(BooleanOption option, String[] servers, String currentServer) {
5458
boolean ban = false;
5559
for (String s : servers) {
5660
if (currentServer.toLowerCase(Locale.ROOT).contains(s.toLowerCase(Locale.ROOT))) {
57-
ban = true;
61+
ban = conditions.get(option).get();
5862
break;
5963
}
6064
}
@@ -64,7 +68,12 @@ private static void disableOption(BooleanOption option, String[] servers, String
6468
}
6569
}
6670

67-
private static void setServers(BooleanOption option, String... servers) {
71+
private static void setServers(BooleanOption option, Supplier<Boolean> condition, String... servers) {
6872
disabledServers.put(option, servers);
73+
conditions.put(option, condition);
74+
}
75+
76+
public static void update(){
77+
disabledServers.forEach((option, strings) -> disableOption(option, strings, currentAdress));
6978
}
7079
}

src/main/resources/assets/axolotlclient/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
"lowFire.tooltip": "Reduces the height of the fire overlay if you are burning",
5050
"lowShield": "Low Shield",
5151
"lowShield.tooltip": "Reduces the height of the shield Overlay while holding or blocking.",
52+
"hitColor": "Hit Color",
53+
"hitColor.tooltip": "The Color used for entities when they are being hurt. <br>Chroma does NOT work for this, since the image used gets <br>regenerated every time this is changed.",
5254

5355
"motionBlur": "Motion Blur",
5456
"zoom": "Zoom",

0 commit comments

Comments
 (0)