Skip to content

Commit

Permalink
add support for different sea levels
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesgreen26 committed Oct 2, 2024
1 parent cc158a1 commit 0793dbc
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/main/java/g_mungus/wakes_compat/ShipWake.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.*;

import static g_mungus.wakes_compat.Util.*;
import static g_mungus.wakes_compat.VSWakesCompat.getSeaLevel;

public class ShipWake {

Expand Down Expand Up @@ -80,7 +81,7 @@ public static void checkShipSize(Ship s) {

Vec3d shipPos = Util.getCentre(s.getWorldAABB());

Double yLevelShip = VectorConversionsMCKt.toJOML(new Vec3d(shipPos.x, 62.9, shipPos.z)).mulPosition(s.getWorldToShip()).y;
Double yLevelShip = VectorConversionsMCKt.toJOML(new Vec3d(shipPos.x, getSeaLevel(), shipPos.z)).mulPosition(s.getWorldToShip()).y;

int blockYLevelShip = yLevelShip.intValue();

Expand Down
21 changes: 15 additions & 6 deletions src/main/java/g_mungus/wakes_compat/VSWakesCompat.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
import com.goby56.wakes.duck.ProducesWake;
import net.fabricmc.api.ClientModInitializer;

import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientEntityEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.util.math.Direction;
Expand Down Expand Up @@ -32,16 +35,25 @@ public class VSWakesCompat implements ClientModInitializer {

private int shipSizeUpdaterCooldown = 0;

private static double seaLevel = 62.9;

@Override
public void onInitializeClient() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
ClientTickEvents.END_CLIENT_TICK.register(client -> onClientTick());
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> onClientJoin(client));

LOGGER.info("Hello Fabric world!");
}

private void onClientJoin(MinecraftClient client) {
if (seaLevel != 63) {
assert client.world != null;
seaLevel = client.world.getSeaLevel() - 0.1;
}
}


private void onClientTick() {
Expand Down Expand Up @@ -72,10 +84,7 @@ private void onClientTick() {
}








public static double getSeaLevel() {
return seaLevel;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.goby56.wakes.particle.custom.SplashPlaneParticle;
import g_mungus.wakes_compat.DynamicWakeSize;
import g_mungus.wakes_compat.Util;
import g_mungus.wakes_compat.VSWakesCompat;
import net.minecraft.util.math.Vec3d;
import org.joml.*;
import org.spongepowered.asm.mixin.Mixin;
Expand Down Expand Up @@ -34,7 +35,7 @@ public boolean onWaterSurface() {

@Override
public float producingHeight() {
return 62.9f;
return (float) VSWakesCompat.getSeaLevel();
}

@Override
Expand Down
Binary file modified src/main/resources/assets/vs-wakes-compat/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 5 additions & 4 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"id": "vs-wakes-compat",
"version": "${version}",
"name": "VS Wakes Compat",
"description": "This is an example description! Tell everyone what your mod is about!",
"description": "Adds wakes behind Valkyrien Skies Ships.",
"authors": [
"Me!"
"G_Mungus"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
"sources": "https://github.com/jamesgreen26/vs2-wakes-compat"
},
"license": "CC0-1.0",
"icon": "assets/vs-wakes-compat/icon.png",
Expand All @@ -26,7 +26,8 @@
"fabricloader": ">=0.16.0",
"minecraft": "~1.20.1",
"java": ">=17",
"fabric-api": "*"
"fabric-api": "*",
"wakes": "0.2.3"
},
"suggests": {
"another-mod": "*"
Expand Down

0 comments on commit 0793dbc

Please sign in to comment.