diff --git a/src/main/java/com/goby56/wakes/WakesClient.java b/src/main/java/com/goby56/wakes/WakesClient.java index 0562811..728d47d 100644 --- a/src/main/java/com/goby56/wakes/WakesClient.java +++ b/src/main/java/com/goby56/wakes/WakesClient.java @@ -26,7 +26,6 @@ public class WakesClient implements ClientModInitializer { public static ModMetadata METADATA; public static final String CONFIG_PATH = String.format("%s/%s.json", FabricLoader.getInstance().getConfigDir().toString(), MOD_ID); public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID); - public static WakesConfig CONFIG_INSTANCE; public static final ManagedCoreShader TRANSLUCENT_NO_LIGHT_DIRECTION_PROGRAM = ShaderEffectManager.getInstance().manageCoreShader( new Identifier(MOD_ID, "translucent_no_light_direction"), VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL); public static boolean areShadersEnabled = false; @@ -37,7 +36,6 @@ public void onInitializeClient() { FabricLoader.getInstance().getModContainer(MOD_ID).ifPresent(container -> METADATA = container.getMetadata()); // Mod configs - CONFIG_INSTANCE = WakesConfig.loadConfig(); MidnightConfig.init(MOD_ID, WakesConfig.class); // Game events diff --git a/src/main/java/com/goby56/wakes/config/WakesConfig.java b/src/main/java/com/goby56/wakes/config/WakesConfig.java index 12d89be..6a0f73b 100644 --- a/src/main/java/com/goby56/wakes/config/WakesConfig.java +++ b/src/main/java/com/goby56/wakes/config/WakesConfig.java @@ -19,8 +19,10 @@ import java.util.Map; public class WakesConfig extends MidnightConfig { + public static final String DEBUG = "Debug"; + // Spawning - public Map effectSpawningRules = new HashMap<>(Map.of( + @Entry() public static Map effectSpawningRules = new HashMap<>(Map.of( "boat", EffectSpawningRule.SIMULATION_AND_PLANES, "player", EffectSpawningRule.ONLY_SIMULATION, "other_players", EffectSpawningRule.ONLY_SIMULATION, @@ -29,28 +31,27 @@ public class WakesConfig extends MidnightConfig { )); // Behaviour - public float wavePropagationFactor = 0.95f; - public float waveDecayFactor = 0.5f; - public int initialStrength = 20; - public int paddleStrength = 100; - public int splashStrength = 100; + @Entry() public static float wavePropagationFactor = 0.95f; + @Entry() public static float waveDecayFactor = 0.5f; + @Entry() public static int initialStrength = 20; + @Entry() public static int paddleStrength = 100; + @Entry() public static int splashStrength = 100; // Debug - public boolean disableMod = false; - public int floodFillDistance = 2; - public int ticksBeforeFill = 2; - public boolean pickBoat = true; - public RenderType renderType = RenderType.AUTO; - public boolean drawDebugBoxes = false; - public boolean showDebugInfo = false; - public float shaderLightPassthrough = 0.5f; - public int maxNodeAge = 30; - public int wakeVisibilityDuration = 0; + @Entry() public static boolean disableMod = false; + @Entry() public static int floodFillDistance = 2; + @Entry() public static int ticksBeforeFill = 2; + @Entry() public static RenderType renderType = RenderType.AUTO; + @Entry() public static boolean drawDebugBoxes = false; + @Entry() public static boolean showDebugInfo = false; + @Entry() public static float shaderLightPassthrough = 0.5f; + @Entry() public static int maxNodeAge = 30; + @Entry() public static int wakeVisibilityDuration = 100; // Appearance - public Resolution wakeResolution = Resolution.SIXTEEN; - public float wakeOpacity = 1f; - public List colorIntervals = List.of( + @Entry() public static Resolution wakeResolution = Resolution.SIXTEEN; + @Entry() public static float wakeOpacity = 1f; + public static List colorIntervals = List.of( new ColorInterval(WakeColor.TRANSPARENT, -50, -45), new ColorInterval(WakeColor.DARK_GRAY, -45, -35), new ColorInterval(WakeColor.GRAY, -35, -30), diff --git a/src/main/java/com/goby56/wakes/debug/DebugCommand.java b/src/main/java/com/goby56/wakes/debug/DebugCommand.java index 7849e18..cd3a5aa 100644 --- a/src/main/java/com/goby56/wakes/debug/DebugCommand.java +++ b/src/main/java/com/goby56/wakes/debug/DebugCommand.java @@ -29,8 +29,6 @@ public static void register(CommandDispatcher dispatc .then(ClientCommandManager.literal("node") .then(ClientCommandManager.argument("flood_level", IntegerArgumentType.integer(0, 5)) .executes(DebugCommand::spawnWakeNode))))); - //.then(ClientCommandManager.literal("splash_cloud_particle") - //.executes(DebugCommand::spawnSplashCloudParticle))))); } public static int spawnWakeNode(CommandContext cmdCtx) throws CommandSyntaxException { diff --git a/src/main/java/com/goby56/wakes/debug/WakeDebugRenderer.java b/src/main/java/com/goby56/wakes/debug/WakeDebugRenderer.java index 2033b8d..78d4780 100644 --- a/src/main/java/com/goby56/wakes/debug/WakeDebugRenderer.java +++ b/src/main/java/com/goby56/wakes/debug/WakeDebugRenderer.java @@ -1,6 +1,7 @@ package com.goby56.wakes.debug; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.simulation.Brick; import com.goby56.wakes.simulation.WakeHandler; import com.goby56.wakes.simulation.WakeNode; @@ -18,7 +19,7 @@ public class WakeDebugRenderer implements WorldRenderEvents.DebugRender { @Override public void beforeDebugRender(WorldRenderContext context) { WakeHandler wakeHandler = WakeHandler.getInstance(); - if (WakesClient.CONFIG_INSTANCE.drawDebugBoxes) { + if (WakesConfig.drawDebugBoxes) { for (var node : wakeHandler.getVisible(context.frustum(), WakeNode.class)) { DebugRenderer.drawBox(node.toBox().offset(context.camera().getPos().negate()), 1, 0, 1, 0.5f); diff --git a/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java b/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java index cddc5cb..9d24290 100644 --- a/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java +++ b/src/main/java/com/goby56/wakes/mixin/DebugHudMixin.java @@ -1,6 +1,7 @@ package com.goby56.wakes.mixin; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.debug.WakesDebugInfo; import net.minecraft.client.gui.hud.DebugHud; import org.spongepowered.asm.mixin.Mixin; @@ -15,8 +16,8 @@ public abstract class DebugHudMixin { @Inject(at = @At("RETURN"), method = "getLeftText") protected void getLeftText(CallbackInfoReturnable> info) { - if (WakesClient.CONFIG_INSTANCE.showDebugInfo) { - if (WakesClient.CONFIG_INSTANCE.disableMod) { + if (WakesConfig.showDebugInfo) { + if (WakesConfig.disableMod) { info.getReturnValue().add("[Wakes] Mod disabled!"); } else { WakesDebugInfo.show(info); diff --git a/src/main/java/com/goby56/wakes/mixin/LilyPadFallMixin.java b/src/main/java/com/goby56/wakes/mixin/LilyPadFallMixin.java index 680a84a..9c6e9e1 100644 --- a/src/main/java/com/goby56/wakes/mixin/LilyPadFallMixin.java +++ b/src/main/java/com/goby56/wakes/mixin/LilyPadFallMixin.java @@ -1,6 +1,7 @@ package com.goby56.wakes.mixin; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.config.enums.EffectSpawningRule; import com.goby56.wakes.duck.ProducesWake; import com.goby56.wakes.simulation.WakeNode; @@ -24,7 +25,7 @@ public class LilyPadFallMixin { @Inject(at = @At("TAIL"), method = "onLandedUpon") public void onLandedUpon(World world, BlockState state, BlockPos pos, Entity entity, float fallDistance, CallbackInfo ci) { if (!world.getBlockState(pos.up()).isOf(Blocks.LILY_PAD)) return; - if (WakesClient.CONFIG_INSTANCE.disableMod) return; + if (WakesConfig.disableMod) return; EffectSpawningRule rule = WakesUtils.getEffectRuleFromSource(entity); ProducesWake wakeProducer = (ProducesWake) entity; if (rule.simulateWakes) { diff --git a/src/main/java/com/goby56/wakes/mixin/WakeSpawnerMixin.java b/src/main/java/com/goby56/wakes/mixin/WakeSpawnerMixin.java index aa33497..820b6c4 100644 --- a/src/main/java/com/goby56/wakes/mixin/WakeSpawnerMixin.java +++ b/src/main/java/com/goby56/wakes/mixin/WakeSpawnerMixin.java @@ -1,13 +1,15 @@ package com.goby56.wakes.mixin; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.config.enums.EffectSpawningRule; import com.goby56.wakes.utils.WakesUtils; import com.goby56.wakes.duck.ProducesWake; +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.entity.Entity; import net.minecraft.util.math.Vec3d; -import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -18,22 +20,24 @@ @Mixin(Entity.class) public abstract class WakeSpawnerMixin implements ProducesWake { - @Shadow public abstract boolean isSubmergedInWater(); @Shadow public abstract String toString(); - @Shadow public abstract boolean isTouchingWater(); @Shadow private Vec3d pos; - @Shadow private World world; - @Unique private boolean onWaterSurface = false; - @Unique private Vec3d prevPosOnSurface = null; + + @Shadow public abstract boolean isOnGround(); + + @Shadow public abstract BlockState getSteppingBlockState(); + + @Unique private boolean inInk = false; + @Unique private Vec3d prevPosInInk = null; @Unique private Vec3d numericalVelocity = Vec3d.ZERO; @Unique private double horizontalNumericalVelocity = 0; @Unique private double verticalNumericalVelocity = 0; - @Unique private Float producingWaterLevel = null; + @Unique private Float producingYLevel = null; @Unique private boolean hasRecentlyTeleported = false; @Override public boolean onWaterSurface() { - return this.onWaterSurface; + return this.inInk; } @Override @@ -52,22 +56,22 @@ public double getVerticalVelocity() { @Override public Vec3d getPrevPos() { - return this.prevPosOnSurface; + return this.prevPosInInk; } @Override public void setPrevPos(Vec3d pos) { - this.prevPosOnSurface = pos; + this.prevPosInInk = pos; } @Override public Float producingWaterLevel() { - return this.producingWaterLevel; + return this.producingYLevel; } @Override public void setProducingHeight(float h) { - this.producingWaterLevel = h; + this.producingYLevel = h; } @Override @@ -77,21 +81,21 @@ public void setRecentlyTeleported(boolean b) { @Inject(at = @At("TAIL"), method = "tick") private void tick(CallbackInfo info) { - this.onWaterSurface = this.isTouchingWater() && !this.isSubmergedInWater(); + this.inInk = this.isOnGround() && this.getSteppingBlockState().isOf(Blocks.OBSIDIAN); Entity thisEntity = ((Entity) (Object) this); Vec3d vel = this.calculateVelocity(thisEntity); this.numericalVelocity = vel; this.horizontalNumericalVelocity = vel.horizontalLength(); this.verticalNumericalVelocity = vel.y; - if (WakesClient.CONFIG_INSTANCE.disableMod) { + if (WakesConfig.disableMod) { return; } - if (this.onWaterSurface && !this.hasRecentlyTeleported) { - this.producingWaterLevel = (float) thisEntity.getPos().y; + if (this.inInk && !this.hasRecentlyTeleported) { + this.producingYLevel = (float) thisEntity.getPos().y; - Vec3d currPos = new Vec3d(thisEntity.getX(), this.producingWaterLevel, thisEntity.getZ()); + Vec3d currPos = new Vec3d(thisEntity.getX(), this.producingYLevel, thisEntity.getZ()); EffectSpawningRule rule = WakesUtils.getEffectRuleFromSource(thisEntity); if (rule.simulateWakes) { @@ -100,8 +104,8 @@ private void tick(CallbackInfo info) { this.setPrevPos(currPos); } else { - this.producingWaterLevel = null; - this.prevPosOnSurface = null; + this.producingYLevel = null; + this.prevPosInInk = null; } this.setRecentlyTeleported(false); } @@ -123,7 +127,7 @@ private Vec3d calculateVelocity(Entity thisEntity) { if (thisEntity instanceof ClientPlayerEntity) { return thisEntity.getVelocity(); } - return this.prevPosOnSurface == null ? Vec3d.ZERO : this.pos.subtract(this.prevPosOnSurface); + return this.prevPosInInk == null ? Vec3d.ZERO : this.pos.subtract(this.prevPosInInk); } } \ No newline at end of file diff --git a/src/main/java/com/goby56/wakes/render/WakeRenderer.java b/src/main/java/com/goby56/wakes/render/WakeRenderer.java index 27ca39f..7e0c603 100644 --- a/src/main/java/com/goby56/wakes/render/WakeRenderer.java +++ b/src/main/java/com/goby56/wakes/render/WakeRenderer.java @@ -1,6 +1,7 @@ package com.goby56.wakes.render; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.config.enums.Resolution; import com.goby56.wakes.simulation.Brick; import com.goby56.wakes.simulation.WakeHandler; @@ -26,7 +27,7 @@ Resolution.THIRTYTWO, new WakeTexture(Resolution.THIRTYTWO.res) @Override public void afterTranslucent(WorldRenderContext context) { - if (WakesClient.CONFIG_INSTANCE.disableMod) { + if (WakesConfig.disableMod) { WakesDebugInfo.quadsRendered = 0; return; } @@ -42,7 +43,7 @@ public void afterTranslucent(WorldRenderContext context) { RenderSystem.enableBlend(); context.lightmapTextureManager().enable(); - Resolution resolution = WakesClient.CONFIG_INSTANCE.wakeResolution; + Resolution resolution = WakesConfig.wakeResolution; if (resolution.res != WakeNode.res) return; int n = 0; long tRendering = System.nanoTime(); diff --git a/src/main/java/com/goby56/wakes/render/WakeTexture.java b/src/main/java/com/goby56/wakes/render/WakeTexture.java index 6868a2f..e423763 100644 --- a/src/main/java/com/goby56/wakes/render/WakeTexture.java +++ b/src/main/java/com/goby56/wakes/render/WakeTexture.java @@ -49,7 +49,7 @@ public void render(Matrix4f matrix, Camera camera, Brick brick) { BufferBuilder buffer = Tessellator.getInstance().getBuffer(); buffer.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL); - Vec3f pos = new Vec3f(brick.pos.add(camera.getPos().negate()).add(0, WakeNode.WATER_OFFSET, 0)); + Vec3f pos = new Vec3f(brick.pos.add(camera.getPos().negate())); int light = LightmapTextureManager.MAX_LIGHT_COORDINATE; buffer.vertex(matrix, pos.getX(), pos.getY(), pos.getZ()) diff --git a/src/main/java/com/goby56/wakes/render/enums/RenderType.java b/src/main/java/com/goby56/wakes/render/enums/RenderType.java index c0662e8..1e7aed8 100644 --- a/src/main/java/com/goby56/wakes/render/enums/RenderType.java +++ b/src/main/java/com/goby56/wakes/render/enums/RenderType.java @@ -2,6 +2,7 @@ import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import net.minecraft.client.render.GameRenderer; import net.minecraft.client.render.Shader; @@ -29,13 +30,13 @@ public enum RenderType { } public static Supplier getProgram() { - if (WakesClient.CONFIG_INSTANCE.renderType == RenderType.AUTO) { + if (WakesConfig.renderType == RenderType.AUTO) { if (WakesClient.areShadersEnabled) { return ENTITY_TRANSLUCENT_CULL.program; } else { return CUSTOM.program; } } - return WakesClient.CONFIG_INSTANCE.renderType.program; + return WakesConfig.renderType.program; } } diff --git a/src/main/java/com/goby56/wakes/render/enums/WakeColor.java b/src/main/java/com/goby56/wakes/render/enums/WakeColor.java index 404c45c..07c735b 100644 --- a/src/main/java/com/goby56/wakes/render/enums/WakeColor.java +++ b/src/main/java/com/goby56/wakes/render/enums/WakeColor.java @@ -6,12 +6,12 @@ public enum WakeColor implements StringIdentifiable { TRANSPARENT(0, 0, 0, 0), - DARK_GRAY(20, 20, 20, 40), - GRAY(50, 50, 50, 100), - LIGHT_GRAY(100, 100, 100, 180), - WHITE(255, 0, 90, 255), - RAT_RED(255, 0, 90, 255), - BLACK(0, 0, 0, 255), + DARK_GRAY(147, 153, 166, 40), + GRAY(158, 165, 176, 100), + LIGHT_GRAY(196, 202, 209, 180), + WHITE(255, 255, 255, 255), + RED(189, 42, 42, 255), + ORANGE(214, 111, 51, 255), YELLOW(227, 225, 84, 255), GREEN(115, 189, 42, 255), CAMO(8, 135, 57, 255), @@ -29,7 +29,7 @@ public enum WakeColor implements StringIdentifiable { private int blend(int waterColor, int lightColor, float opacity, boolean isWhite) { float srcA = (this.abgr >>> 24 & 0xFF) / 255f; int a = (int) (opacity * 255 * srcA); - int b = 90, g = 0, r = 255; + int b = 255, g = 255, r = 255; if (!isWhite) { b = (int) ((this.abgr >> 16 & 0xFF) * (1 - srcA) + (waterColor & 0xFF) * (srcA)); g = (int) ((this.abgr >> 8 & 0xFF) * (1 - srcA) + (waterColor >> 8 & 0xFF) * (srcA)); @@ -43,13 +43,13 @@ private int blend(int waterColor, int lightColor, float opacity, boolean isWhite } private static double invertedLogisticCurve(float x) { - float k = WakesClient.CONFIG_INSTANCE.shaderLightPassthrough; + float k = WakesConfig.shaderLightPassthrough; return WakesClient.areShadersEnabled ? k * (4 * Math.pow(x - 0.5f, 3) + 0.5f) : x; } public static int getColor(float waveEqAvg, int waterColor, int lightColor, float opacity) { double clampedRange = 100 / (1 + Math.exp(-0.1 * waveEqAvg)) - 50; - for (WakesConfig.ColorInterval interval : WakesClient.CONFIG_INSTANCE.colorIntervals) { + for (WakesConfig.ColorInterval interval : WakesConfig.colorIntervals) { if (interval.lower <= clampedRange && clampedRange <= interval.upper) { return interval.color.blend(waterColor, lightColor, opacity, interval.color == WakeColor.WHITE); } diff --git a/src/main/java/com/goby56/wakes/simulation/Brick.java b/src/main/java/com/goby56/wakes/simulation/Brick.java index a10508c..13df235 100644 --- a/src/main/java/com/goby56/wakes/simulation/Brick.java +++ b/src/main/java/com/goby56/wakes/simulation/Brick.java @@ -1,6 +1,6 @@ package com.goby56.wakes.simulation; -import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.render.enums.WakeColor; import com.goby56.wakes.debug.WakesDebugInfo; import net.minecraft.client.MinecraftClient; @@ -40,7 +40,7 @@ public Brick(int x, float y, int z, int width) { this.capacity = dim * dim; this.nodes = new WakeNode[dim][dim]; this.pos = new Vec3d(x, y, z); - initTexture(WakesClient.CONFIG_INSTANCE.wakeResolution.res); + initTexture(WakesConfig.wakeResolution.res); } public void initTexture(int res) { @@ -190,8 +190,8 @@ public void populatePixels() { LightmapTextureManager.getSkyLightCoordinates(lightCoordinate) ); // TODO LERP LIGHT FROM SURROUNDING BLOCKS - float f = node.t / WakesClient.CONFIG_INSTANCE.wakeVisibilityDuration; - opacity = (float) (Math.exp(-f*f) * WakesClient.CONFIG_INSTANCE.wakeOpacity); + float f = node.t / WakesConfig.wakeVisibilityDuration; + opacity = (float) (Math.exp(-f*f) * WakesConfig.wakeOpacity); } // TODO MASS SET PIXELS TO NO COLOR IF NODE DOESNT EXIST (NEED TO REORDER PIXELS STORED?) diff --git a/src/main/java/com/goby56/wakes/simulation/WakeHandler.java b/src/main/java/com/goby56/wakes/simulation/WakeHandler.java index b6ba5d8..ba6c4d9 100644 --- a/src/main/java/com/goby56/wakes/simulation/WakeHandler.java +++ b/src/main/java/com/goby56/wakes/simulation/WakeHandler.java @@ -1,6 +1,7 @@ package com.goby56.wakes.simulation; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.config.enums.Resolution; import com.goby56.wakes.debug.WakesDebugInfo; import net.minecraft.client.MinecraftClient; @@ -103,7 +104,7 @@ private int getYLevel(int i) { } public static void scheduleResolutionChange(Resolution newRes) { - WakesClient.CONFIG_INSTANCE.wakeResolution = newRes; + WakesConfig.wakeResolution = newRes; WakeHandler wakeHandler = WakeHandler.getInstance(); if (wakeHandler == null) { return; @@ -113,7 +114,7 @@ public static void scheduleResolutionChange(Resolution newRes) { private void changeResolution() { this.reset(); - WakeNode.res = WakesClient.CONFIG_INSTANCE.wakeResolution.res; + WakeNode.res = WakesConfig.wakeResolution.res; this.resolutionResetScheduled = false; } diff --git a/src/main/java/com/goby56/wakes/simulation/WakeNode.java b/src/main/java/com/goby56/wakes/simulation/WakeNode.java index 6816e9d..b19bfa9 100644 --- a/src/main/java/com/goby56/wakes/simulation/WakeNode.java +++ b/src/main/java/com/goby56/wakes/simulation/WakeNode.java @@ -1,7 +1,10 @@ package com.goby56.wakes.simulation; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.utils.WakesUtils; +import net.minecraft.block.Block; +import net.minecraft.block.Blocks; import net.minecraft.client.MinecraftClient; import net.minecraft.entity.Entity; import net.minecraft.entity.vehicle.BoatEntity; @@ -15,7 +18,7 @@ import java.util.*; public class WakeNode { - public static int res = WakesClient.CONFIG_INSTANCE.wakeResolution.res; + public static int res = WakesConfig.wakeResolution.res; private static float alpha; private static float beta; @@ -52,7 +55,7 @@ public WakeNode(Vec3d position, int initialStrength) { this.u[0][sz+1+z][sx+1+x] = initialStrength; } } - this.floodLevel = WakesClient.CONFIG_INSTANCE.floodFillDistance; + this.floodLevel = WakesConfig.floodFillDistance; } private WakeNode(int x, int y, int z, int floodLevel) { @@ -69,7 +72,7 @@ private WakeNode(long pos, int y) { this.x = xz[0]; this.y = y; this.z = xz[1]; - this.floodLevel = WakesClient.CONFIG_INSTANCE.floodFillDistance; + this.floodLevel = WakesConfig.floodFillDistance; } private void initValues() { @@ -92,14 +95,14 @@ public void setInitialValue(long pos, int val) { public static void calculateWaveDevelopmentFactors() { float time = 20f; // ticks // TODO CHANGE "16" TO ACTUAL RES? MAYBE? - WakeNode.alpha = (float) Math.pow(WakesClient.CONFIG_INSTANCE.wavePropagationFactor * 16f / time, 2); - WakeNode.beta = (float) (Math.log(10 * WakesClient.CONFIG_INSTANCE.waveDecayFactor + 10) / Math.log(20)); // Logarithmic scale + WakeNode.alpha = (float) Math.pow(WakesConfig.wavePropagationFactor * 16f / time, 2); + WakeNode.beta = (float) (Math.log(10 * WakesConfig.waveDecayFactor + 10) / Math.log(20)); // Logarithmic scale } public boolean tick() { - int maxAge = WakesClient.CONFIG_INSTANCE.maxNodeAge; + int maxAge = WakesConfig.maxNodeAge; if (this.isDead()) return false; - if (this.age++ >= maxAge || res != WakesClient.CONFIG_INSTANCE.wakeResolution.res) { + if (this.age++ >= maxAge || res != WakesConfig.wakeResolution.res) { this.markDead(); return false; } @@ -140,7 +143,7 @@ public boolean tick() { public void floodFill() { WakeHandler wh = WakeHandler.getInstance(); assert wh != null; - if (floodLevel > 0 && this.age > WakesClient.CONFIG_INSTANCE.ticksBeforeFill) { + if (floodLevel > 0 && this.age > WakesConfig.ticksBeforeFill) { if (this.NORTH == null) { wh.insert(new WakeNode(this.x, this.y, this.z - 1, floodLevel - 1)); } else { @@ -196,8 +199,7 @@ public void updateFloodLevel(int newLevel) { } public boolean validPos(World world) { - // Return true if in ink - return true; + return world.getBlockState(this.blockPos().down()).isOf(Blocks.OBSIDIAN); } public Box toBox() { @@ -206,7 +208,7 @@ public Box toBox() { public void revive(WakeNode node) { this.age = 0; - this.floodLevel = WakesClient.CONFIG_INSTANCE.floodFillDistance; + this.floodLevel = WakesConfig.floodFillDistance; this.initialValues = node.initialValues; } @@ -254,7 +256,7 @@ public static Set splashNodes(Entity entity, int y) { } } } - return pixelsToNodes(pixelsAffected, y, WakesClient.CONFIG_INSTANCE.splashStrength, Math.abs(entity.getVelocity().y)); + return pixelsToNodes(pixelsAffected, y, WakesConfig.splashStrength, Math.abs(entity.getVelocity().y)); } public static Set rowingNodes(BoatEntity boat, int y) { @@ -271,7 +273,7 @@ public static Set rowingNodes(BoatEntity boat, int y) { Vec3d dir = Vec3d.fromPolar(0, boat.getYaw()).multiply(velocity); Vec3d from = paddlePos; Vec3d to = paddlePos.add(dir.multiply(2)); - nodesAffected.addAll(nodeTrail(from.x, from.z, to.x, to.z, y, WakesClient.CONFIG_INSTANCE.paddleStrength, velocity)); + nodesAffected.addAll(nodeTrail(from.x, from.z, to.x, to.z, y, WakesConfig.paddleStrength, velocity)); } } } diff --git a/src/main/java/com/goby56/wakes/utils/WakesUtils.java b/src/main/java/com/goby56/wakes/utils/WakesUtils.java index e5287aa..92b5772 100644 --- a/src/main/java/com/goby56/wakes/utils/WakesUtils.java +++ b/src/main/java/com/goby56/wakes/utils/WakesUtils.java @@ -1,6 +1,7 @@ package com.goby56.wakes.utils; import com.goby56.wakes.WakesClient; +import com.goby56.wakes.config.WakesConfig; import com.goby56.wakes.config.enums.EffectSpawningRule; import com.goby56.wakes.duck.ProducesWake; import com.goby56.wakes.simulation.WakeHandler; @@ -50,13 +51,13 @@ public static void placeWakeTrail(Entity entity) { if (prevPos == null) { return; } - for (WakeNode node : WakeNode.Factory.thickNodeTrail(prevPos.x, prevPos.z, entity.getX(), entity.getZ(), y, WakesClient.CONFIG_INSTANCE.initialStrength, velocity, entity.getWidth())) { + for (WakeNode node : WakeNode.Factory.thickNodeTrail(prevPos.x, prevPos.z, entity.getX(), entity.getZ(), y, WakesConfig.initialStrength, velocity, entity.getWidth())) { wakeHandler.insert(node); } } public static EffectSpawningRule getEffectRuleFromSource(Entity source) { - Map effectRule = WakesClient.CONFIG_INSTANCE.effectSpawningRules; + Map effectRule = WakesConfig.effectSpawningRules; if (source instanceof BoatEntity boat) { List passengers = boat.getPassengerList(); if (passengers.contains(MinecraftClient.getInstance().player)) {