Skip to content
Merged
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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.13-SNAPSHOT'
id 'fabric-loom' version "${loom_version}"
id 'maven-publish'
id 'me.fallenbreath.yamlang' version '1.4.1'
}
Expand Down
15 changes: 8 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@ org.gradle.parallel=true

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.21.10
loader_version=0.17.3
minecraft_version=1.21.11
loader_version=0.18.2
loom_version=1.14-SNAPSHOT

# Fabric API
fabric_version=0.138.3+1.21.10
fabric_version=0.139.5+1.21.11

# Mod Properties
mod_version=0.4.4+1.21.10
mod_version=0.5.0+1.21.11
maven_group=com.goby56.wakes
archives_base_name=wakes

# Dependencies
midnightlib_version=1.8.3+1.21.9-fabric
iris_version=1.9.6+1.21.10-fabric
modmenu_version=16.0.0-rc.1
midnightlib_version=1.9.2+1.21.11-fabric
iris_version=1.10.2+1.21.11-fabric
modmenu_version=17.0.0-alpha.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-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.0-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
30 changes: 10 additions & 20 deletions src/main/java/com/goby56/wakes/WakesClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@
import com.goby56.wakes.particle.ModParticles;
import com.goby56.wakes.render.SplashPlaneRenderer;
import com.goby56.wakes.render.WakeRenderer;
import com.mojang.blaze3d.pipeline.BlendFunction;
import com.mojang.blaze3d.pipeline.RenderPipeline;
import com.mojang.blaze3d.platform.DepthTestFunction;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.VertexFormat;
import eu.midnightdust.lib.config.MidnightConfig;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.fabricmc.fabric.api.client.rendering.v1.world.WorldRenderEvents;
import net.fabricmc.fabric.api.entity.event.v1.ServerEntityWorldChangeEvents;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.metadata.ModMetadata;
import net.irisshaders.iris.api.v0.IrisApi;
import net.minecraft.client.gui.components.debug.DebugScreenEntries;
import net.minecraft.client.renderer.RenderPipelines;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -35,19 +32,12 @@ public class WakesClient implements ClientModInitializer {
public static boolean areShadersEnabled = false;
public static final RenderPipeline GUI_HSV_PIPELINE = RenderPipelines.register(
RenderPipeline.builder(RenderPipelines.GUI_TEXTURED_SNIPPET)
.withLocation(ResourceLocation.fromNamespaceAndPath("wakes", "pipeline/gui_hsv"))
.withFragmentShader(ResourceLocation.fromNamespaceAndPath("wakes", "gui_hsv"))
.withLocation(Identifier.fromNamespaceAndPath("wakes", "pipeline/gui_hsv"))
.withFragmentShader(Identifier.fromNamespaceAndPath("wakes", "gui_hsv"))
.build()
);
public static final RenderPipeline SPLASH_PLANE_PIPELINE = RenderPipelines.register(
RenderPipeline.builder(RenderPipelines.BEACON_BEAM_SNIPPET)
.withLocation("pipeline/beacon_beam_translucent")
.withVertexFormat(DefaultVertexFormat.BLOCK, VertexFormat.Mode.TRIANGLES)
.withDepthWrite(false)
.withCull(false)
.withDepthTestFunction(DepthTestFunction.LEQUAL_DEPTH_TEST)
.withBlend(BlendFunction.TRANSLUCENT)
.build());

public static WakeRenderer wakeRenderer;

@Override
public void onInitializeClient() {
Expand All @@ -65,13 +55,13 @@ public void onInitializeClient() {
ServerEntityWorldChangeEvents.AFTER_PLAYER_CHANGE_WORLD.register(new WakeWorldTicker());

// Rendering events
WorldRenderEvents.END_MAIN.register(new WakeRenderer());
wakeRenderer = new WakeRenderer();
WorldRenderEvents.END_MAIN.register(wakeRenderer);
WorldRenderEvents.END_MAIN.register(new SplashPlaneRenderer());
WorldRenderEvents.BEFORE_DEBUG_RENDER.register(new WakeDebugRenderer());

SplashPlaneRenderer.initSplashPlane();
DebugScreenEntries.register(
ResourceLocation.fromNamespaceAndPath("wakes", "debug_entry"),
Identifier.fromNamespaceAndPath("wakes", "debug_entry"),
new WakesDebugInfo());
}

Expand All @@ -81,4 +71,4 @@ public static boolean areShadersEnabled() {
}
return false;
}
}
}
4 changes: 4 additions & 0 deletions src/main/java/com/goby56/wakes/config/enums/Resolution.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public enum Resolution {
this.power = Mth.log2(res);
}

public static Resolution getHighest() {
return THIRTYTWO;
}

@Override
public String toString() {
return String.valueOf(this.res);
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/com/goby56/wakes/config/gui/ColorPicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import net.minecraft.client.gui.components.AbstractSliderButton;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.util.Mth;
import org.joml.Matrix3x2f;
import org.joml.Vector2f;
Expand All @@ -26,9 +26,9 @@
import java.util.regex.Pattern;

public class ColorPicker extends AbstractWidget {
private static final ResourceLocation FRAME_TEXTURE = ResourceLocation.withDefaultNamespace("textures/gui/sprites/widget/slot_frame.png");
private static final ResourceLocation PICKER_BG_TEXTURE = ResourceLocation.fromNamespaceAndPath(WakesClient.MOD_ID, "textures/picker_background.png");
private static final ResourceLocation PICKER_KNOB_TEXTURE = ResourceLocation.fromNamespaceAndPath(WakesClient.MOD_ID, "textures/picker_knob.png");
private static final Identifier FRAME_TEXTURE = Identifier.withDefaultNamespace("textures/gui/sprites/widget/slot_frame.png");
private static final Identifier PICKER_BG_TEXTURE = Identifier.fromNamespaceAndPath(WakesClient.MOD_ID, "textures/picker_background.png");
private static final Identifier PICKER_KNOB_TEXTURE = Identifier.fromNamespaceAndPath(WakesClient.MOD_ID, "textures/picker_knob.png");
private static final int pickerKnobDim = 7;

private final Map<String, Bounded> widgets = new HashMap<>();
Expand Down Expand Up @@ -355,7 +355,7 @@ public void renderWidget(GuiGraphics context, int mouseX, int mouseY, float delt
}
context.blitSprite(RenderPipelines.GUI_TEXTURED, this.getHandleSprite(), this.getX() + (int)(this.value * (double)(this.width - 8)), this.getY(), 8, this.getHeight());
int i = this.active ? 0xFFFFFF : 0xA0A0A0;
this.renderScrollingString(context, Minecraft.getInstance().font, 2, i | Mth.ceil(this.alpha * 255.0f) << 24);
this.renderScrollingStringOverContents(context.textRenderer(), this.message, i | Mth.ceil(this.alpha * 255.0f) << 24);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;

public class ColorPickerScreen extends Screen {
private final Screen parent;
private boolean showInfoText = false;
private ColorIntervalSlider colorIntervalSlider;
private WakeAffectingSlider wakeOpacitySlider;
private WakeAffectingSlider blendStrengthSlider;
private static final ResourceLocation INFO_ICON_TEXTURE = ResourceLocation.fromNamespaceAndPath("minecraft", "textures/gui/sprites/icon/info.png");
private static final ResourceLocation RESET_ICON_TEXTURE = ResourceLocation.fromNamespaceAndPath(WakesClient.MOD_ID, "textures/reset_icon.png");
private static final Identifier INFO_ICON_TEXTURE = Identifier.fromNamespaceAndPath("minecraft", "textures/gui/sprites/icon/info.png");
private static final Identifier RESET_ICON_TEXTURE = Identifier.fromNamespaceAndPath(WakesClient.MOD_ID, "textures/reset_icon.png");
public ColorPickerScreen(Screen parent) {
super(Component.nullToEmpty("Configure wake colors"));
this.parent = parent;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/goby56/wakes/config/gui/SliderHandle.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package com.goby56.wakes.config.gui;

import com.goby56.wakes.render.WakeColor;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;

public class SliderHandle implements Comparable<SliderHandle> {

private static final ResourceLocation HANDLE_TEXTURE = ResourceLocation.withDefaultNamespace("widget/slider_handle");
private static final ResourceLocation HANDLE_HIGHLIGHTED_TEXTURE = ResourceLocation.withDefaultNamespace("widget/slider_handle_highlighted");
private static final Identifier HANDLE_TEXTURE = Identifier.withDefaultNamespace("widget/slider_handle");
private static final Identifier HANDLE_HIGHLIGHTED_TEXTURE = Identifier.withDefaultNamespace("widget/slider_handle_highlighted");

protected WakeColor color;
protected float value;
Expand All @@ -31,7 +31,7 @@ public boolean inProximity(float value, int sliderWidth, int handleWidth) {
return (Math.abs(value - this.value) < (float) handleWidth / (2 * sliderWidth));
}

public ResourceLocation getHandleTexture(boolean isHovered) {
public Identifier getHandleTexture(boolean isHovered) {
if (focused || isHovered) {
return HANDLE_HIGHLIGHTED_TEXTURE;
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/goby56/wakes/config/gui/TexturedButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;

public class TexturedButton extends Button {
private final ResourceLocation texture;
private final Identifier texture;
private final int textureWidth;
private final int textureHeight;
protected TexturedButton(int width, int height, OnPress onPress, ResourceLocation texture, int texWidth, int texHeight) {
protected TexturedButton(int width, int height, OnPress onPress, Identifier texture, int texWidth, int texHeight) {
super(0, 0, width, height, Component.empty(), onPress, DEFAULT_NARRATION);
this.texture = texture;
this.textureWidth = texWidth;
Expand All @@ -22,20 +22,20 @@ public static com.goby56.wakes.config.gui.TexturedButton.Builder builder(Button.
}

@Override
protected void renderWidget(GuiGraphics context, int mouseX, int mouseY, float delta) {
super.renderWidget(context, mouseX, mouseY, delta);
protected void renderContents(GuiGraphics context, int mouseX, int mouseY, float delta) {
int tw = this.textureWidth;
int th = this.textureHeight;
int x = this.getX() + this.getWidth() / 2 - this.textureWidth / 2;
int y = this.getY() + this.getHeight() / 2 - this.textureHeight / 2;
context.blit(RenderPipelines.GUI_TEXTURED, this.texture, x, y, 0, 0, tw, th, tw, th);

}

public static class Builder {
private final Button.OnPress onPress;
private int width = 30;
private int height = 30;
private ResourceLocation texture;
private Identifier texture;
private int textureWidth = 20;
private int textureHeight = 20;

Expand All @@ -49,7 +49,7 @@ public com.goby56.wakes.config.gui.TexturedButton.Builder dimension(int width, i
return this;
}

public com.goby56.wakes.config.gui.TexturedButton.Builder texture(ResourceLocation texture, int width, int height) {
public com.goby56.wakes.config.gui.TexturedButton.Builder texture(Identifier texture, int width, int height) {
this.texture = texture;
this.textureWidth = width;
this.textureHeight = height;
Expand Down
38 changes: 16 additions & 22 deletions src/main/java/com/goby56/wakes/debug/WakeDebugRenderer.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
package com.goby56.wakes.debug;

import com.goby56.wakes.config.WakesConfig;
import com.goby56.wakes.simulation.Brick;
import com.goby56.wakes.render.WakeColor;
import com.goby56.wakes.simulation.WakeChunk;
import com.goby56.wakes.simulation.WakeHandler;
import com.goby56.wakes.simulation.WakeNode;
import net.fabricmc.fabric.api.client.rendering.v1.world.WorldRenderContext;
import net.fabricmc.fabric.api.client.rendering.v1.world.WorldRenderEvents;
import net.minecraft.client.Camera;
import net.minecraft.client.renderer.debug.DebugRenderer;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElement;
import net.minecraft.gizmos.GizmoStyle;
import net.minecraft.gizmos.Gizmos;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.Vec3;

import java.awt.*;
import java.util.Random;

public class WakeDebugRenderer implements WorldRenderEvents.DebugRender {

@Override
public void beforeDebugRender(WorldRenderContext context) {
public class WakeDebugRenderer {
public static void addDebugGizmos() {
WakeHandler wakeHandler = WakeHandler.getInstance().orElse(null);
if (wakeHandler == null) return;
int color = new WakeColor(255, 0, 255, 128).argb;

if (WakesConfig.drawDebugBoxes) {
Camera camera = context.gameRenderer().getMainCamera();
for (var node : wakeHandler.getVisible(WakeNode.class)) {
DebugRenderer.renderFilledBox(context.matrices(), context.consumers(),
node.toBox().move(camera.getPosition().reverse()),
1, 0, 1, 0.5f);
for (var node : wakeHandler.getVisibleNodes()) {
Gizmos.cuboid(node.toBox(), GizmoStyle.fill(color));
}
for (var brick : wakeHandler.getVisible(Brick.class)) {
Vec3 pos = brick.pos;
AABB box = new AABB(pos.x, pos.y - (1 - WakeNode.WATER_OFFSET), pos.z, pos.x + brick.dim, pos.y, pos.z + brick.dim);
var col = Color.getHSBColor(new Random(pos.hashCode()).nextFloat(), 1f, 1f).getRGBColorComponents(null);
DebugRenderer.renderFilledBox(context.matrices(), context.consumers(),
box.move(camera.getPosition().reverse()),
col[0], col[1], col[2], 0.5f);
for (var chunk : wakeHandler.getVisibleChunks()) {
Vec3 pos = chunk.pos;
AABB box = new AABB(pos.x, pos.y - (1 - WakeNode.WATER_OFFSET), pos.z, pos.x + WakeChunk.WIDTH, pos.y, pos.z + WakeChunk.WIDTH);
var col = Color.getHSBColor(new Random(pos.hashCode()).nextFloat(), 1f, 1f).getRGB();
Gizmos.cuboid(box, GizmoStyle.fill(col));
}
}

}
}
4 changes: 2 additions & 2 deletions src/main/java/com/goby56/wakes/debug/WakesDebugInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import com.goby56.wakes.config.WakesConfig;
import net.minecraft.client.gui.components.debug.DebugScreenDisplayer;
import net.minecraft.client.gui.components.debug.DebugScreenEntry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.resources.Identifier;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.chunk.LevelChunk;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -31,7 +31,7 @@ public void display(DebugScreenDisplayer debugScreenDisplayer, @Nullable Level l
if (WakesConfig.disableMod) {
debugScreenDisplayer.addLine("[Wakes] Mod disabled!");
} else {
debugScreenDisplayer.addToGroup(ResourceLocation.fromNamespaceAndPath("wakes", "debug_category"),
debugScreenDisplayer.addToGroup(Identifier.fromNamespaceAndPath("wakes", "debug_category"),
List.of(
String.format("[Wakes] Rendering %d quads for %d wake nodes", WakesDebugInfo.quadsRendered, WakesDebugInfo.nodeCount),
String.format("[Wakes] Node logic: %.2fms/t", 10e-6 * WakesDebugInfo.nodeLogicTime),
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/goby56/wakes/event/WakeWorldTicker.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.goby56.wakes.event;

import com.goby56.wakes.WakesClient;
import com.goby56.wakes.debug.WakeDebugRenderer;
import com.goby56.wakes.simulation.WakeHandler;
import com.goby56.wakes.debug.WakesDebugInfo;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
Expand All @@ -16,6 +17,7 @@ public void onEndTick(ClientLevel world) {
WakesClient.areShadersEnabled = WakesClient.areShadersEnabled();
WakesDebugInfo.reset();
WakeHandler.getInstance().ifPresent(WakeHandler::tick);
WakeDebugRenderer.addDebugGizmos();
}

@Override
Expand Down
Loading
Loading