Skip to content

Commit

Permalink
brought back flyingSpeedCap
Browse files Browse the repository at this point in the history
  • Loading branch information
IoIxD committed Dec 28, 2023
1 parent af34bcb commit 8e226ba
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
15 changes: 4 additions & 11 deletions src/main/java/net/ioixd/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;

import com.moandjiezana.toml.Toml;
import net.fabricmc.fabric.api.networking.v1.FabricPacket;
Expand All @@ -17,7 +16,7 @@ public class Config implements FabricPacket {

public boolean cappedSpeed = true;
public double speedCap = 0.15;
public double flyingSpeedMul = 2.0;
public double flyingSpeedCap = 0.15;
public double legendaryModifier = 0.05;

public boolean allowFlying = true;
Expand All @@ -33,7 +32,7 @@ public void write(PacketByteBuf p) {
p.writeBoolean(cappedSpeed);
p.writeDouble(speedCap);
p.writeDouble(legendaryModifier);
p.writeDouble(flyingSpeedMul);
p.writeDouble(flyingSpeedCap);
p.writeBoolean(allowFlying);
p.writeBoolean(allowSwimming);
p.writeEnumConstant(listUse);
Expand Down Expand Up @@ -113,7 +112,7 @@ public void update() throws Exception {
this.cappedSpeed = toml.getBoolean("cappedSpeed", true);
this.speedCap = toml.getDouble("speedCap", 0.15);
this.legendaryModifier = toml.getDouble("legenedaryModifier", 0.05);
this.flyingSpeedMul = toml.getDouble("flyingSpeedMul", 2.0);
this.flyingSpeedCap = toml.getDouble("flyingSpeedCap", 0.15);
this.allowFlying = toml.getBoolean("allowFlying", true);
this.allowSwimming = toml.getBoolean("allowSwimming", true);
String listUse = toml.getString("listUse", "").toLowerCase();
Expand All @@ -134,20 +133,14 @@ public void update() throws Exception {
this.alsoFlyList = toml.getList("alsoFlying", new ArrayList<String>()).stream().map(f -> {
return f.toLowerCase();
}).toList();

double flyingSpeedCap = toml.getDouble("flyingSpeedCap", 0.0);
if (flyingSpeedCap != 0.0) {
Logger.getGlobal().warning(
"flyingSpeedCap is no longer a valid key. It is replaced with flyingSpeedMul, and it acts as a multiplier for flying/swimming Pokemon's speed in the air.");
}
}

public static Config read(PacketByteBuf p) {
var config = new Config();
config.cappedSpeed = p.readBoolean();
config.speedCap = p.readDouble();
config.legendaryModifier = p.readDouble();
config.flyingSpeedMul = p.readDouble();
config.flyingSpeedCap = p.readDouble();
config.allowFlying = p.readBoolean();
config.allowSwimming = p.readBoolean();
config.listUse = p.readEnumConstant(ListUse.class);
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/net/ioixd/client/mixin/PokemonMovementHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ protected void tickControlled(PlayerEntity player, Vec3d movement) {
Block water = pokemon.getBlockStateAtPos().getBlock();
boolean inLiquid = water instanceof FluidBlock;

float speedModifier = pokemonData.isLegendary() ? 0.0f
: (float) CobblemountsClient.SYNCED_CONFIG.legendaryModifier;
AtomicBoolean isFlying = new AtomicBoolean(false);
Vec3d moveXZ = movement;// movement.rotateY((float) Math.toRadians(-player.getYaw()));
Vec3d forward = player.getRotationVector().normalize().multiply(movement.z);
Expand Down Expand Up @@ -100,9 +102,13 @@ protected void tickControlled(PlayerEntity player, Vec3d movement) {
;
if (condition) {
if (flyMove.z != 0.0) {

pokemon.move(MovementType.SELF,
flyMove.multiply(CobblemountsClient.SYNCED_CONFIG.flyingSpeedMul));
double flyingSpeed = ((pokemonData.getSpeed() / 64.0f) + speedModifier) * 8.0;
if (CobblemountsClient.SYNCED_CONFIG.cappedSpeed) {
if (flyingSpeed >= CobblemountsClient.SYNCED_CONFIG.flyingSpeedCap) {
flyingSpeed = CobblemountsClient.SYNCED_CONFIG.flyingSpeedCap;
}
}
pokemon.move(MovementType.SELF, flyMove.multiply(flyingSpeed));
isFlying.set(true);
}
if (flying) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/cobblemounts.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cappedSpeed = true
speedCap = 0.5
flyingSpeedMul = 2.0 # Also applies to swimming Pokemon.
speedCap = 0.4
flyingSpeedCap = 3.0 # Also applies to swimming Pokemon.
legendaryModifier = 0.05 # Legendaries get an additive boost to their speed (this is capped by the speed cap)
allowFlying = true
allowSwimming = true
Expand Down

0 comments on commit 8e226ba

Please sign in to comment.