Skip to content

Commit 1dd5aa2

Browse files
committed
Added Zoom
1 parent d2be922 commit 1dd5aa2

File tree

14 files changed

+149
-16
lines changed

14 files changed

+149
-16
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ org.gradle.jvmargs=-Xmx1G
33
org.gradle.parallel=true
44

55
# SimpleClient
6-
simpleclient_version=0.1.0-dev
6+
simpleclient_version=0.1.1-dev

simpleclient-1.19.4/src/main/java/simpleclient/feature/FeatureManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public class FeatureManagerImpl extends FeatureManager {
1111
@Override
1212
public void init() {
13-
KeyMapping editFeaturesKey = KeyBindingHelper.registerKeyBinding(new KeyMapping("simpleclient.edit_features", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_RIGHT_SHIFT, "key.categories.simpleclient"));
13+
KeyMapping editFeaturesKey = KeyBindingHelper.registerKeyBinding(new KeyMapping("simpleclient.edit_features", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_RIGHT_SHIFT, "simpleclient.category"));
1414
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
1515
if (editFeaturesKey.consumeClick() && minecraft.screen == null && minecraft.level != null) {
1616
minecraft.setScreen(new EditFeaturesScreen());
@@ -19,6 +19,7 @@ public void init() {
1919
addFeature(new FPS());
2020
addFeature(new PerformanceBoost());
2121
addFeature(new Motionblur());
22+
addFeature(new Zoom());
2223
super.init();
2324
}
2425
}

simpleclient-1.19.4/src/main/java/simpleclient/feature/PerformanceBoost.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ public PerformanceBoost() {
2323

2424
public void refresh() {
2525
ENABLED = isEnabled();
26-
JsonObject data = getData();
27-
FASTBOOT = ENABLED && fastBoot.load(data);
28-
DONT_RENDER_CLOUDS = ENABLED && dontRenderCouds.load(data);
29-
DONT_RENDER_SKY_UNDER_WATER = ENABLED && dontRenderSkyUnderWater.load(data);
26+
FASTBOOT = ENABLED && getConfigValue(fastBoot);
27+
DONT_RENDER_CLOUDS = ENABLED && getConfigValue(dontRenderCouds);
28+
DONT_RENDER_SKY_UNDER_WATER = ENABLED && getConfigValue(dontRenderSkyUnderWater);
3029
}
3130

3231
@Override
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package simpleclient.feature;
2+
3+
import com.google.gson.JsonObject;
4+
import com.mojang.blaze3d.platform.InputConstants;
5+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
6+
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
7+
import net.minecraft.client.KeyMapping;
8+
import net.minecraft.network.chat.Component;
9+
import org.lwjgl.glfw.GLFW;
10+
import simpleclient.feature.config.EnableConfigEntry;
11+
import simpleclient.feature.config.FloatConfigEntry;
12+
13+
public class Zoom extends Feature {
14+
public static boolean ACTIVE = false;
15+
public static float ZOOM_FACTOR = 0;
16+
private FloatConfigEntry zoomFactor = new FloatConfigEntry("zoom_factor", Component.translatable("simpleclient.zoom.zoom_factor"), 0.8F, value -> Component.literal("x" + (float) (int) (10 / (1 - value)) / 10));
17+
private EnableConfigEntry smoothCamera = new EnableConfigEntry("smooth_camera", Component.translatable("simpleclient.zoom.smooth_camera"), true);
18+
19+
public Zoom() {
20+
super(FeatureType.ZOOM);
21+
KeyMapping zoomKey = KeyBindingHelper.registerKeyBinding(new KeyMapping("simpleclient.zoom", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_C, "simpleclient.category"));
22+
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
23+
if (zoomKey.isDown() && !ACTIVE) {
24+
ACTIVE = true;
25+
minecraft.options.smoothCamera = getConfigValue(smoothCamera);
26+
} else if (!zoomKey.isDown() && ACTIVE) {
27+
ACTIVE = false;
28+
minecraft.options.smoothCamera = false;
29+
}
30+
});
31+
addConfigEntry(zoomFactor);
32+
addConfigEntry(smoothCamera);
33+
refresh();
34+
}
35+
36+
public void refresh() {
37+
ZOOM_FACTOR = getConfigValue(zoomFactor);
38+
}
39+
40+
@Override
41+
public void setData(JsonObject data) {
42+
super.setData(data);
43+
refresh();
44+
}
45+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package simpleclient.mixin;
2+
3+
import net.minecraft.client.Camera;
4+
import net.minecraft.client.renderer.GameRenderer;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
9+
import simpleclient.feature.Zoom;
10+
11+
@Mixin(GameRenderer.class)
12+
public abstract class GameRendererMixin {
13+
@Inject(at = @At(value = "RETURN"), method = "getFov", cancellable = true)
14+
public void getFov(Camera camera, float tickDelta, boolean changingFov, CallbackInfoReturnable<Double> cir) {
15+
if (Zoom.ACTIVE) cir.setReturnValue(cir.getReturnValue() * (1 - Zoom.ZOOM_FACTOR));
16+
}
17+
}

simpleclient-1.19.4/src/main/resources/simpleclient.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"mixins": [
77
],
88
"client": [
9+
"GameRendererMixin",
910
"GuiMixin",
1011
"performance.LevelRendererMixin",
1112
"performance.OptionsMixin",

simpleclient-1.20/src/main/java/simpleclient/feature/FeatureManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public class FeatureManagerImpl extends FeatureManager {
1111
@Override
1212
public void init() {
13-
KeyMapping editFeaturesKey = KeyBindingHelper.registerKeyBinding(new KeyMapping("simpleclient.edit_features", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_RIGHT_SHIFT, "key.categories.simpleclient"));
13+
KeyMapping editFeaturesKey = KeyBindingHelper.registerKeyBinding(new KeyMapping("simpleclient.edit_features", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_RIGHT_SHIFT, "simpleclient.category"));
1414
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
1515
if (editFeaturesKey.consumeClick() && minecraft.screen == null && minecraft.level != null) {
1616
minecraft.setScreen(new EditFeaturesScreen());
@@ -19,6 +19,7 @@ public void init() {
1919
addFeature(new FPS());
2020
addFeature(new PerformanceBoost());
2121
//addFeature(new Motionblur());
22+
addFeature(new Zoom());
2223
super.init();
2324
}
2425
}

simpleclient-1.20/src/main/java/simpleclient/feature/PerformanceBoost.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ public PerformanceBoost() {
2323

2424
public void refresh() {
2525
ENABLED = isEnabled();
26-
JsonObject data = getData();
27-
FASTBOOT = ENABLED && fastBoot.load(data);
28-
DONT_RENDER_CLOUDS = ENABLED && dontRenderCouds.load(data);
29-
DONT_RENDER_SKY_UNDER_WATER = ENABLED && dontRenderSkyUnderWater.load(data);
26+
FASTBOOT = ENABLED && getConfigValue(fastBoot);
27+
DONT_RENDER_CLOUDS = ENABLED && getConfigValue(dontRenderCouds);
28+
DONT_RENDER_SKY_UNDER_WATER = ENABLED && getConfigValue(dontRenderSkyUnderWater);
3029
}
3130

3231
@Override
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package simpleclient.feature;
2+
3+
import com.google.gson.JsonObject;
4+
import com.mojang.blaze3d.platform.InputConstants;
5+
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
6+
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
7+
import net.minecraft.client.KeyMapping;
8+
import net.minecraft.network.chat.Component;
9+
import org.lwjgl.glfw.GLFW;
10+
import simpleclient.feature.config.EnableConfigEntry;
11+
import simpleclient.feature.config.FloatConfigEntry;
12+
13+
public class Zoom extends Feature {
14+
public static boolean ACTIVE = false;
15+
public static float ZOOM_FACTOR = 0;
16+
private FloatConfigEntry zoomFactor = new FloatConfigEntry("zoom_factor", Component.translatable("simpleclient.zoom.zoom_factor"), 0.8F, value -> Component.literal("x" + (float) (int) (10 / (1 - value)) / 10));
17+
private EnableConfigEntry smoothCamera = new EnableConfigEntry("smooth_camera", Component.translatable("simpleclient.zoom.smooth_camera"), true);
18+
19+
public Zoom() {
20+
super(FeatureType.ZOOM);
21+
KeyMapping zoomKey = KeyBindingHelper.registerKeyBinding(new KeyMapping("simpleclient.zoom", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_C, "simpleclient.category"));
22+
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
23+
if (zoomKey.isDown() && !ACTIVE) {
24+
ACTIVE = true;
25+
minecraft.options.smoothCamera = getConfigValue(smoothCamera);
26+
} else if (!zoomKey.isDown() && ACTIVE) {
27+
ACTIVE = false;
28+
minecraft.options.smoothCamera = false;
29+
}
30+
});
31+
addConfigEntry(zoomFactor);
32+
addConfigEntry(smoothCamera);
33+
refresh();
34+
}
35+
36+
public void refresh() {
37+
ZOOM_FACTOR = getConfigValue(zoomFactor);
38+
}
39+
40+
@Override
41+
public void setData(JsonObject data) {
42+
super.setData(data);
43+
refresh();
44+
}
45+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package simpleclient.mixin;
2+
3+
import net.minecraft.client.Camera;
4+
import net.minecraft.client.renderer.GameRenderer;
5+
import org.spongepowered.asm.mixin.Mixin;
6+
import org.spongepowered.asm.mixin.injection.At;
7+
import org.spongepowered.asm.mixin.injection.Inject;
8+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
9+
import simpleclient.feature.Zoom;
10+
11+
@Mixin(GameRenderer.class)
12+
public abstract class GameRendererMixin {
13+
@Inject(at = @At(value = "RETURN"), method = "getFov", cancellable = true)
14+
public void getFov(Camera camera, float tickDelta, boolean changingFov, CallbackInfoReturnable<Double> cir) {
15+
if (Zoom.ACTIVE) cir.setReturnValue(cir.getReturnValue() * (1 - Zoom.ZOOM_FACTOR));
16+
}
17+
}

0 commit comments

Comments
 (0)