diff --git a/src/main/java/committee/nova/boatoverhaul/client/BoatOverhaulClient.java b/src/main/java/committee/nova/boatoverhaul/client/BoatOverhaulClient.java index c6bc92e..98e3758 100644 --- a/src/main/java/committee/nova/boatoverhaul/client/BoatOverhaulClient.java +++ b/src/main/java/committee/nova/boatoverhaul/client/BoatOverhaulClient.java @@ -9,6 +9,10 @@ public class BoatOverhaulClient implements ClientModInitializer { private static boolean allowSteeringWhenStopped; private static boolean reverseRudderWhenSailingAstern; private static double speedMultiplier; + private static int gearX; + private static int gearY; + private static int rudderX; + private static int rudderY; private static Config config; @Override @@ -22,11 +26,24 @@ public void onInitializeClient() { reverseRudderWhenSailingAstern=false # The multiplier of the maximum sailing speed speedMultiplier=1.0 + # The X Offset of gear indicator + gearX=0 + # The Y Offset of gear indicator + gearY=0 + # The X Offset of rudder indicator + rudderX=0 + # The Y Offset of rudder indicator + rudderY=0 """ ).request(); allowSteeringWhenStopped = config.getOrDefault("allowRudderingWhenStopped", false); reverseRudderWhenSailingAstern = config.getOrDefault("reverseRudderWhenSailingAstern", false); speedMultiplier = config.getOrDefault("speedMultiplier", 1.0); + gearX = config.getOrDefault("gearX", 0); + gearY = config.getOrDefault("gearY", 0); + rudderX = config.getOrDefault("rudderX", 0); + rudderY = config.getOrDefault("rudderY", 0); + KeyBindingHelper.registerKeyBinding(Keys.keyLeftRudder); KeyBindingHelper.registerKeyBinding(Keys.keyRightRudder); } @@ -47,4 +64,20 @@ public static boolean shouldReverseRudderWhenSailingAstern() { public static double getSpeedMultiplier() { return speedMultiplier; } + + public static int getGearX() { + return gearX; + } + + public static int getGearY() { + return gearY; + } + + public static int getRudderX() { + return rudderX; + } + + public static int getRudderY() { + return rudderY; + } } diff --git a/src/main/java/committee/nova/boatoverhaul/client/overlay/init/OverlayInit.java b/src/main/java/committee/nova/boatoverhaul/client/overlay/init/OverlayInit.java index d305658..a64533a 100644 --- a/src/main/java/committee/nova/boatoverhaul/client/overlay/init/OverlayInit.java +++ b/src/main/java/committee/nova/boatoverhaul/client/overlay/init/OverlayInit.java @@ -7,6 +7,7 @@ import committee.nova.boatoverhaul.api.client.widget.IRudderWidget; import committee.nova.boatoverhaul.api.client.widget.IWidget; import committee.nova.boatoverhaul.api.common.boat.IBoat; +import committee.nova.boatoverhaul.client.BoatOverhaulClient; import committee.nova.boatoverhaul.client.overlay.CursorWidgets; import committee.nova.boatoverhaul.client.overlay.GearWidgets; import committee.nova.boatoverhaul.client.overlay.RudderWidgets; @@ -29,10 +30,10 @@ public static void renderBoatOverlay(PoseStack matrix) { final Minecraft mc = Minecraft.getInstance(); final int height = mc.getWindow().getGuiScaledHeight(); final int width = mc.getWindow().getGuiScaledWidth(); - final int gearXOffset = width / 2 - 50; - final int gearYOffset = height / 2 - 30; - final int rudderXOffset = width / 2 - 12; - final int rudderYOffset = height / 2 + 60; + final int gearXOffset = width / 2 - 50 + BoatOverhaulClient.getGearX(); + final int gearYOffset = height / 2 - 30 + BoatOverhaulClient.getGearY(); + final int rudderXOffset = width / 2 - 12 + BoatOverhaulClient.getRudderX(); + final int rudderYOffset = height / 2 + 60 + BoatOverhaulClient.getRudderY(); matrix.pushPose(); startRender(); RenderSystem.setShaderTexture(0, overlay); @@ -66,13 +67,13 @@ private static void renderRudderScale(Rudder target, PoseStack matrix, int x, in private static void renderGearCursor(Gear currentGear, int accumulationOffset, PoseStack matrix, int x, int y) { final IWidget g = CursorWidgets.GEAR_CURSOR; - final int actualY = y - currentGear.getNumerator() * 10 - accumulationOffset; + final int actualY = y - currentGear.getNumerator() * 10 / 4 - accumulationOffset / 4; GuiComponent.blit(matrix, x, actualY, g.getStartX(), g.getStartY(), g.getWidth(), g.getHeight(), 256, 256); } private static void renderRudderCursor(Rudder currentRudder, int accumulationOffset, PoseStack matrix, int x, int y) { final IWidget r = CursorWidgets.RUDDER_CURSOR; - final int actualX = x + currentRudder.getNumerator() * 25 + accumulationOffset; + final int actualX = x + currentRudder.getNumerator() * 25 / 4 + accumulationOffset / 4; GuiComponent.blit(matrix, actualX, y, r.getStartX(), r.getStartY(), r.getWidth(), r.getHeight(), 256, 256); } diff --git a/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Gear.java b/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Gear.java index c8b07c9..1d36f2d 100644 --- a/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Gear.java +++ b/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Gear.java @@ -3,12 +3,27 @@ import committee.nova.boatoverhaul.api.common.boat.shiftable.IShiftable; public enum Gear implements IShiftable { - ASTERN(-1, 4), - STOP(0, 4), - ONE_QUARTER(1, 4), - ONE_HALF(2, 4), - THREE_QUARTERS(3, 4), - FULL(4, 4); + ASTERN(-4, 16), + N3(-3, 16), + N2(-2, 16), + N1(-1, 16), + STOP(0, 16), + P1(1, 16), + P2(2, 16), + P3(3, 16), + ONE_QUARTER(4, 16), + P5(5, 16), + P6(6, 16), + P7(7, 16), + ONE_HALF(8, 16), + P9(9, 16), + P10(10, 16), + P11(11, 16), + THREE_QUARTERS(12, 16), + P13(13, 16), + P14(14, 16), + P15(15, 16), + FULL(16, 16); private final int numerator; private final int denominator; @@ -28,7 +43,7 @@ public int getDenominator() { } public static int getMinimumNumerator() { - return -1; + return -4; } public static Gear getGearFromNumerator(int numerator) { diff --git a/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Rudder.java b/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Rudder.java index 9e00f40..117d0fb 100644 --- a/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Rudder.java +++ b/src/main/java/committee/nova/boatoverhaul/common/boat/gear/Rudder.java @@ -3,14 +3,27 @@ import committee.nova.boatoverhaul.api.common.boat.shiftable.IShiftable; public enum Rudder implements IShiftable { - FULL_LEFT(-2, 2), - HALF_LEFT(-1, 2), - ZERO(0, 2), - HALF_RIGHT(1, 2), - FULL_RIGHT(2, 2); + FULL_LEFT(-8, 8), + L7(-7, 8), + L6(-6, 8), + L5(-5, 8), + HALF_LEFT(-4, 8), + L3(-3, 8), + L2(-2, 8), + L1(-1, 8), + ZERO(0, 8), + R1(1, 8), + R2(2, 8), + R3(3, 8), + HALF_RIGHT(4, 8), + R5(5, 8), + R6(6, 8), + R7(7, 8), + FULL_RIGHT(8, 8); private final int numerator; private final int denominator; + public static final Rudder[] EXPLICITS = {FULL_LEFT, HALF_LEFT, ZERO, HALF_RIGHT, FULL_RIGHT}; Rudder(int numerator, int denominator) { this.numerator = numerator; @@ -28,7 +41,7 @@ public int getDenominator() { } public static int getMinimumNumerator() { - return -2; + return -8; } public static Rudder getRudderFromNumerator(int numerator) { @@ -36,4 +49,12 @@ public static Rudder getRudderFromNumerator(int numerator) { for (final Rudder t : Rudder.values()) if (numerator == t.numerator) r = t; return r; } + + public static Rudder getNearestExplicitRudder(int numerator, boolean right) { + final Rudder raw = getRudderFromNumerator(numerator); + for (final Rudder t : EXPLICITS) + if (right != (t.getNumerator() > raw.getNumerator()) && Math.abs(t.getNumerator() - raw.getNumerator()) < 4) + return t; + return raw; + } } diff --git a/src/main/java/committee/nova/boatoverhaul/mixin/MixinBoat.java b/src/main/java/committee/nova/boatoverhaul/mixin/MixinBoat.java index e43c435..4b1f0f8 100644 --- a/src/main/java/committee/nova/boatoverhaul/mixin/MixinBoat.java +++ b/src/main/java/committee/nova/boatoverhaul/mixin/MixinBoat.java @@ -27,9 +27,9 @@ public abstract class MixinBoat extends Entity implements IBoat { private int gearCd; private int rudderCd; private int rudderAccumulation; - private final int maxRudderAccumulation = 20; + private final int maxRudderAccumulation = 5; private int gearAccumulation; - private final int maxGearAccumulation = 20; + private final int maxGearAccumulation = 5; private boolean inputLRudder; private boolean inputRRudder; private Rudder targetRudder; @@ -157,18 +157,18 @@ private void handleRuddering() { if (this.rudderCd == 0 && this.inputLRudder && !this.inputRRudder) { if (targetRudder == null) targetRudder = this.rudderState.getRudder(); final int origin = targetRudder.getNumerator(); - final int current = Math.max(targetRudder.getNumerator() - 1, Rudder.getMinimumNumerator()); + final int current = Math.max(targetRudder.getNumerator() - 4, Rudder.getMinimumNumerator()); if (origin != current) { - targetRudder = Rudder.getRudderFromNumerator(current); + targetRudder = Rudder.getNearestExplicitRudder(current, false); rudderCd = 5; Utilities.getSoundFromShiftable(targetRudder).ifPresent(SoundUtil::playUISound); } } else if (this.rudderCd == 0 && !this.inputLRudder && this.inputRRudder) { if (targetRudder == null) targetRudder = this.rudderState.getRudder(); final int origin = targetRudder.getNumerator(); - final int current = Math.min(targetRudder.getNumerator() + 1, targetRudder.getDenominator()); + final int current = Math.min(targetRudder.getNumerator() + 4, targetRudder.getDenominator()); if (origin != current) { - targetRudder = Rudder.getRudderFromNumerator(current); + targetRudder = Rudder.getNearestExplicitRudder(current, true); rudderCd = 5; Utilities.getSoundFromShiftable(targetRudder).ifPresent(SoundUtil::playUISound); } @@ -211,7 +211,7 @@ private void handleGearing() { if (this.gearCd > 0) gearCd--; if (this.gearCd == 0 && this.inputUp && !this.inputDown) { final int original = getTargetGear().getNumerator(); - final int current = Math.min(getTargetGear().getNumerator() + 1, getTargetGear().getDenominator()); + final int current = Math.min(getTargetGear().getNumerator() + 4, getTargetGear().getDenominator()); if (original != current) { targetGear = Gear.getGearFromNumerator(current); gearCd = 5; @@ -221,7 +221,7 @@ private void handleGearing() { } } else if (this.gearCd == 0 && !this.inputUp && this.inputDown) { final int original = getTargetGear().getNumerator(); - final int current = Math.max(getTargetGear().getNumerator() - 1, Gear.getMinimumNumerator()); + final int current = Math.max(getTargetGear().getNumerator() - 4, Gear.getMinimumNumerator()); if (original != current) { targetGear = Gear.getGearFromNumerator(current); gearCd = 5; diff --git a/src/main/java/committee/nova/boatoverhaul/util/Utilities.java b/src/main/java/committee/nova/boatoverhaul/util/Utilities.java index ceb4b3b..70e2694 100644 --- a/src/main/java/committee/nova/boatoverhaul/util/Utilities.java +++ b/src/main/java/committee/nova/boatoverhaul/util/Utilities.java @@ -13,17 +13,17 @@ public static Optional getSoundFromShiftable(IShiftable s) { Optional option = Optional.empty(); if (s instanceof final Gear g) { switch (g.getNumerator()) { - case -1 -> option = Sounds.getSound(Sounds.GEAR_ASTERN); - case 1 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_1); - case 2 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_2); - case 3 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_3); - case 4 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_4); + case -4 -> option = Sounds.getSound(Sounds.GEAR_ASTERN); + case 4 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_1); + case 8 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_2); + case 12 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_3); + case 16 -> option = Sounds.getSound(Sounds.GEAR_AHEAD_4); default -> option = Sounds.getSound(Sounds.GEAR_STOP); } } if (s instanceof final Rudder r) { switch (r.getNumerator()) { - case -2, 2 -> option = Sounds.getSound(Sounds.RUDDER_FULL); + case -8, 8 -> option = Sounds.getSound(Sounds.RUDDER_FULL); default -> option = Sounds.getSound(Sounds.RUDDER_HALF); } }