mirror of
https://github.com/JonasunderscoreJones/nicer-skies.git
synced 2025-10-22 19:29:18 +02:00
new: config wip 2
This commit is contained in:
parent
a421a55cf7
commit
38fedc823e
6 changed files with 92 additions and 15 deletions
|
@ -1,14 +1,17 @@
|
|||
package codes.ztereohype.example.gui;
|
||||
|
||||
import codes.ztereohype.example.config.Config;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import codes.ztereohype.example.NicerSkies;
|
||||
import codes.ztereohype.example.config.ConfigManager;
|
||||
import codes.ztereohype.example.gui.widget.Separator;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.components.Checkbox;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class ConfigScreen extends Screen {
|
||||
private Screen lastScreen;
|
||||
private ConfigManager cm = NicerSkies.config;
|
||||
protected ConfigScreen(Screen lastScreen) {
|
||||
super(Component.literal("Nicer Skies Config"));
|
||||
this.lastScreen = lastScreen;
|
||||
|
@ -16,16 +19,39 @@ public class ConfigScreen extends Screen {
|
|||
|
||||
@Override
|
||||
public void init() {
|
||||
Field[] fields = Config.class.getFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
int finalI = i;
|
||||
addRenderableWidget(new Button(0, 0, 100, 20, Component.literal(fields[i].getName()), (button) -> {
|
||||
try {
|
||||
fields[finalI].setBoolean(null, !fields[finalI].getBoolean(null));
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}));
|
||||
}
|
||||
addRenderableWidget(new Checkbox(20, 60, 20, 20, Component.literal("Render nebulas"), cm.getNebulas()) {
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
cm.setNebulas(!cm.getNebulas());
|
||||
}
|
||||
});
|
||||
addRenderableWidget(new Checkbox(20, 90, 20, 20, Component.literal("Twinlke Stars"), cm.getTwinklingStars()) {
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
cm.setTwinklingStars(!cm.getTwinklingStars());
|
||||
}
|
||||
});
|
||||
addRenderableWidget(new Checkbox(20, 120, 20, 20, Component.literal("Custom Lightmap"), cm.getLightmapTweaked()) {
|
||||
@Override
|
||||
public void onPress() {
|
||||
super.onPress();
|
||||
cm.setLightmapTweaked(!cm.getLightmapTweaked());
|
||||
}
|
||||
});
|
||||
addRenderableOnly(new Separator(this.width / 2, 30, this.height - 40));
|
||||
|
||||
addRenderableWidget(new Slider)
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
|
||||
this.renderBackground(poseStack);
|
||||
super.render(poseStack, mouseX, mouseY, partialTick);
|
||||
|
||||
drawCenteredString(poseStack, this.font, this.title, this.width / 2, 10, 16777215);
|
||||
drawCenteredString(poseStack, this.font, "Toggle Features", this.width / 4, 36, 16777215);
|
||||
drawCenteredString(poseStack, this.font, "Nebula Settings", 3 * this.width / 4, 36, 16777215);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package codes.ztereohype.example.gui;
|
||||
|
||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||
import net.fabricmc.api.EnvType;
|
||||
import net.fabricmc.api.Environment;
|
||||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public class ModMenuSettingsApi implements ModMenuApi {
|
||||
@Override
|
||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||
return ConfigScreen::new;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package codes.ztereohype.example.gui.widget;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.Widget;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Separator extends GuiComponent implements Widget {
|
||||
private final int x;
|
||||
private final int y;
|
||||
private final int height;
|
||||
|
||||
public Separator(int x, int y, int height) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(@NotNull PoseStack poseStack, int mouseX, int mouseY, float partialTick) {
|
||||
fill(poseStack, x, y, x + 1, y + height, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package codes.ztereohype.example.mixin;
|
||||
|
||||
import codes.ztereohype.example.NicerSkies;
|
||||
import com.mojang.math.Vector3f;
|
||||
import net.minecraft.client.multiplayer.ClientLevel;
|
||||
import net.minecraft.client.renderer.LightTexture;
|
||||
|
@ -17,6 +18,7 @@ public abstract class MixinLightTexutre {
|
|||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void injectWarmLight(float partialTicks, CallbackInfo ci, ClientLevel clientLevel, float f, float g, float h, float i, float j, float l, float k, Vector3f vector3f, float m, Vector3f vector3f2, int n, int o, float p, float q, float r, float s, float t, boolean bl, float v, Vector3f vector3f5) {
|
||||
if (!NicerSkies.config.getLightmapTweaked()) return;
|
||||
Vector3f warmTint = new Vector3f(0.36F, 0.13F, -0.15F);
|
||||
|
||||
float warmness = o / 15f * // increase w/ blocklight
|
||||
|
|
|
@ -37,6 +37,7 @@ public abstract class MixinStarRendering {
|
|||
|
||||
@Inject(at = @At("HEAD"), method = "tick")
|
||||
private void tickStars(CallbackInfo ci) {
|
||||
if (!NicerSkies.config.getTwinklingStars()) return;
|
||||
if (this.level.getStarBrightness(0) < 0.0F) return;
|
||||
NicerSkies.skyManager.tick(ticks, starBuffer);
|
||||
}
|
||||
|
@ -56,6 +57,7 @@ public abstract class MixinStarRendering {
|
|||
locals = LocalCapture.CAPTURE_FAILHARD
|
||||
)
|
||||
private void drawSkybox(PoseStack poseStack, Matrix4f projectionMatrix, float partialTick, Camera camera, boolean bl, Runnable skyFogSetup, CallbackInfo ci, FogType fogType, Vec3 vec3, float f, float g, float h, BufferBuilder bufferBuilder, ShaderInstance shaderInstance, float[] fs, float i, Matrix4f matrix4f2, float k, int r, int s, int m, float t, float o, float p, float q) {
|
||||
if (!NicerSkies.config.getNebulas()) return;
|
||||
float alpha = 2 * level.getStarBrightness(partialTick) * (1.0F - this.level.getRainLevel(partialTick));
|
||||
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, alpha);
|
||||
NicerSkies.skyManager.getSkybox().render(poseStack, projectionMatrix);
|
||||
|
|
|
@ -16,6 +16,9 @@
|
|||
"entrypoints": {
|
||||
"main": [
|
||||
"codes.ztereohype.example.NicerSkies"
|
||||
],
|
||||
"modmenu": [
|
||||
"codes.ztereohype.example.gui.ModMenuSettingsApi"
|
||||
]
|
||||
},
|
||||
"mixins": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue