Skip to content

Commit 4fbc134

Browse files
authored
Merge branch 'main' into performance
2 parents af00b13 + cc1ee0c commit 4fbc134

File tree

23 files changed

+428
-69
lines changed

23 files changed

+428
-69
lines changed

simpleclient-1.19.4/build.gradle

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ plugins {
44
}
55

66
repositories {
7+
maven { url = "https://ladysnake.jfrog.io/artifactory/mods" }
78
}
89

910
dependencies {
@@ -16,6 +17,12 @@ dependencies {
1617
include project(path: ':simpleclient-core')
1718
// Dependencies
1819
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_api_version}"
20+
modImplementation "io.github.ladysnake:satin:${project.satin_version}"
21+
include "io.github.ladysnake:satin:${project.satin_version}"
22+
}
23+
24+
sourceSets {
25+
main.resources.srcDirs += "${project(':simpleclient-core').projectDir}/src/main/resources"
1926
}
2027

2128
processResources {

simpleclient-1.19.4/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ minecraft_version=1.19.4
33
fabric_loader_version=0.14.19
44

55
# Dependencies
6-
fabric_api_version=0.77.0+1.19.4
6+
fabric_api_version=0.77.0+1.19.4
7+
satin_version=1.12.1

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,14 @@ public class FeatureManagerImpl extends FeatureManager {
1313
public void init() {
1414
Minecraft mc = Minecraft.getInstance();
1515
KeyMapping editFeaturesKey = KeyBindingHelper.registerKeyBinding(new KeyMapping("simpleclient.edit_features", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_RIGHT_SHIFT, "key.categories.simpleclient"));
16-
ClientTickEvents.END_CLIENT_TICK.register(c -> {
17-
if (editFeaturesKey.consumeClick() && mc.screen == null && mc.level != null) {
18-
mc.setScreen(new EditFeaturesScreen());
16+
ClientTickEvents.END_CLIENT_TICK.register(minecraft -> {
17+
if (editFeaturesKey.consumeClick() && minecraft.screen == null && minecraft.level != null) {
18+
minecraft.setScreen(new EditFeaturesScreen());
1919
}
2020
});
2121
addFeature(new FPS());
2222
addFeature(new PerformanceBoost());
23+
addFeature(new Motionblur());
2324
super.init();
2425
}
2526
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package simpleclient.feature;
2+
3+
import ladysnake.satin.api.event.ShaderEffectRenderCallback;
4+
import ladysnake.satin.api.managed.ManagedShaderEffect;
5+
import ladysnake.satin.api.managed.ShaderEffectManager;
6+
import net.minecraft.network.chat.Component;
7+
import net.minecraft.resources.ResourceLocation;
8+
import net.minecraft.util.Mth;
9+
import simpleclient.feature.config.PercentConfigEntry;
10+
11+
public class Motionblur extends EnableableFeature {
12+
private final ManagedShaderEffect shader = ShaderEffectManager.getInstance().manage(new ResourceLocation("simpleclient", "shaders/post/motionblur.json"), shader -> {});
13+
private final PercentConfigEntry strength = new PercentConfigEntry("strength", Component.translatable("simpleclient.motionblur.strength"), 0.25F, 0);
14+
15+
public Motionblur() {
16+
super(FeatureType.MOTIONBLUR);
17+
addConfigEntry(strength);
18+
ShaderEffectRenderCallback.EVENT.register(tickDelta -> {
19+
if (isEnabled()) {
20+
float strengthValue = log(Math.pow(100.0F, 0.01F), getConfigValue(strength) * 100) / 100;
21+
shader.setUniformValue("strength", Math.max(0, Math.min(strengthValue, 1)));
22+
shader.render(tickDelta);
23+
}
24+
});
25+
}
26+
27+
private float log(double base, double number) {
28+
return (float) (Math.log(number) / Math.log(base));
29+
}
30+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package simpleclient.feature.config;
2+
3+
import com.google.gson.JsonObject;
4+
import net.minecraft.client.gui.components.AbstractWidget;
5+
import net.minecraft.client.gui.components.Button;
6+
import net.minecraft.network.chat.CommonComponents;
7+
import net.minecraft.network.chat.Component;
8+
import simpleclient.feature.Feature;
9+
10+
import java.util.function.Function;
11+
import java.util.function.Supplier;
12+
13+
public class EnableConfigEntry implements ConfigEntry<Boolean> {
14+
private String key;
15+
private boolean defaultValue;
16+
private Component displayText;
17+
18+
public EnableConfigEntry(String key, Component displayText, boolean defaultValue) {
19+
this.key = key;
20+
this.defaultValue = defaultValue;
21+
this.displayText = displayText;
22+
}
23+
24+
@Override
25+
public Boolean load(JsonObject json) {
26+
if (!json.has(key)) json.addProperty(key, defaultValue);
27+
return json.get(key).getAsBoolean();
28+
}
29+
30+
@Override
31+
public void save(JsonObject json, Boolean value) {
32+
json.addProperty(key, value);
33+
}
34+
35+
@Override
36+
public AbstractWidget createWidget(Feature feature) {
37+
Function<Boolean, Component> text = value -> displayText.copy().append(": ").append(value ? CommonComponents.OPTION_ON : CommonComponents.OPTION_OFF);
38+
return Button.builder(text.apply(feature.getConfigValue(this)), button -> {
39+
boolean value = feature.getConfigValue(this);
40+
feature.setConfigValue(this, !value);
41+
button.setMessage(text.apply(!value));
42+
}).size(200, 20).build();
43+
}
44+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package simpleclient.feature.config;
2+
3+
import com.google.gson.JsonObject;
4+
import net.minecraft.client.gui.components.AbstractOptionSliderButton;
5+
import net.minecraft.client.gui.components.AbstractSliderButton;
6+
import net.minecraft.client.gui.components.AbstractWidget;
7+
import net.minecraft.client.gui.components.Button;
8+
import net.minecraft.network.chat.CommonComponents;
9+
import net.minecraft.network.chat.Component;
10+
import simpleclient.feature.Feature;
11+
12+
import java.util.function.Function;
13+
14+
public class FloatConfigEntry implements ConfigEntry<Float> {
15+
private String key;
16+
private float defaultValue;
17+
private Component displayText;
18+
private Function<Float, Component> valueText;
19+
20+
public FloatConfigEntry(String key, Component displayText, float defaultValue, Function<Float, Component> valueText) {
21+
this.key = key;
22+
this.defaultValue = defaultValue;
23+
this.displayText = displayText;
24+
this.valueText = valueText;
25+
}
26+
27+
@Override
28+
public Float load(JsonObject json) {
29+
if (!json.has(key)) json.addProperty(key, defaultValue);
30+
return json.get(key).getAsFloat();
31+
}
32+
33+
@Override
34+
public void save(JsonObject json, Float value) {
35+
json.addProperty(key, value);
36+
}
37+
38+
@Override
39+
public AbstractWidget createWidget(Feature feature) {
40+
Function<Float, Component> text = value -> displayText.copy().append(": ").append(valueText.apply(value));
41+
float value = feature.getConfigValue(this);
42+
return new AbstractSliderButton(0, 0, 200, 20, text.apply(value), value) {
43+
@Override
44+
protected void updateMessage() {
45+
setMessage(text.apply((float) value));
46+
}
47+
48+
@Override
49+
protected void applyValue() {
50+
feature.setConfigValue(FloatConfigEntry.this, (float) value);
51+
}
52+
};
53+
}
54+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package simpleclient.feature.config;
2+
3+
import net.minecraft.network.chat.Component;
4+
5+
import java.util.function.Function;
6+
7+
public class PercentConfigEntry extends FloatConfigEntry {
8+
public PercentConfigEntry(String key, Component displayText, float defaultValue, int digits) {
9+
super(key, displayText, defaultValue, v -> Component.literal((float) (int) (v * Math.pow(10, digits + 2)) / Math.pow(10, digits) + "%"));
10+
}
11+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package simpleclient.gui;
2+
3+
import com.mojang.blaze3d.vertex.PoseStack;
4+
import net.minecraft.client.gui.Gui;
5+
import net.minecraft.client.gui.GuiComponent;
6+
import net.minecraft.client.gui.components.AbstractSliderButton;
7+
import net.minecraft.client.gui.components.AbstractWidget;
8+
import net.minecraft.client.gui.components.Button;
9+
import net.minecraft.client.gui.screens.Screen;
10+
import net.minecraft.network.chat.CommonComponents;
11+
import net.minecraft.network.chat.Component;
12+
import simpleclient.feature.Feature;
13+
14+
import java.util.ArrayList;
15+
import java.util.List;
16+
17+
public class EditFeatureConfigScreen extends Screen {
18+
private final Feature feature;
19+
private final Screen parent;
20+
21+
public EditFeatureConfigScreen(Feature feature, Screen parent) {
22+
super(Component.translatable("simpleclient.edit_feature_config"));
23+
this.feature = feature;
24+
this.parent = parent;
25+
}
26+
27+
@Override
28+
protected void init() {
29+
List<AbstractWidget> widgets = new ArrayList<>();
30+
int y = 20 + font.lineHeight;
31+
widgets.add(Button.builder(CommonComponents.GUI_DONE, button -> minecraft.setScreen(parent)).size(200, 20).build());
32+
feature.getConfig().forEach(e -> widgets.add((AbstractWidget) e.createWidget(feature)));
33+
for (int i = 0; i < widgets.size(); i++) {
34+
AbstractWidget widget = widgets.get(i);
35+
widget.setX((width - widget.getWidth()) / 2);
36+
widget.setY(y);
37+
y += widget.getHeight() + 2;
38+
addRenderableWidget(widget);
39+
}
40+
}
41+
42+
@Override
43+
public void render(PoseStack poseStack, int mouseX, int mouseY, float delta) {
44+
renderBackground(poseStack);
45+
Component text = Component.translatable("simpleclient.edit_config_of", feature.getName());
46+
GuiComponent.drawCenteredString(poseStack, font, text, width / 2, 10, 0xFFFFFFFF);
47+
super.render(poseStack, mouseX, mouseY, delta);
48+
}
49+
50+
@Override
51+
public void onClose() {
52+
minecraft.setScreen(parent);
53+
}
54+
}

0 commit comments

Comments
 (0)