Skip to content

Commit

Permalink
speed config didn't apply to flying mons
Browse files Browse the repository at this point in the history
  • Loading branch information
IoIxD committed Oct 26, 2023
1 parent a29bd8a commit 49234a4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/main/java/net/ioixd/Cobblemounts.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@

import net.fabricmc.fabric.api.event.player.UseEntityCallback;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.ioixd.Config.ListUse;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
Expand All @@ -18,10 +14,6 @@
import org.slf4j.LoggerFactory;

import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.item.CobblemonItem;
import com.cobblemon.mod.common.item.group.CobblemonItemGroups;

import kotlin.jvm.JvmStatic;

public class Cobblemounts implements ModInitializer {
public static final String MOD_ID = "Cobblemounts";
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/ioixd/mixin/PokemonMovementHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ private void travel(Vec3d movement, CallbackInfo info) {
living.bodyYaw = living.headYaw = player.getYaw();
entity.setPitch(entity.getPitch());

living.setMovementSpeed(player.getMovementSpeed() * (pokemon.getSpeed() / 12.0f));

Block water = living.getBlockStateAtPos().getBlock();
boolean inLiquid = water instanceof FluidBlock;

Expand Down Expand Up @@ -115,12 +113,14 @@ private void travel(Vec3d movement, CallbackInfo info) {
default -> living.getBlockPos();
};
BlockState state = world.getBlockState(forwardPos);
System.out.println("forwardPos: " + forwardPos);
Block forwardBlock = state.getBlock();
if (!forwardBlock.isTransparent(state, world, forwardPos)
&& !(forwardBlock instanceof FluidBlock)) {
BlockPos upperPos = new BlockPos(forwardPos.getX(), forwardPos.getY() + 1, forwardPos.getZ());
BlockState upperState = world.getBlockState(upperPos);
Block upperBlock = upperState.getBlock();
System.out.println("upperPos: " + upperPos);
if (upperBlock.isTransparent(upperState, world, upperPos)) {
living.teleport(upperPos.getX(), upperPos.getY(), upperPos.getZ());
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/net/ioixd/mixin/PokemonUpdateTick.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@ private void tickMovement(CallbackInfo info) {
entity.bodyYaw = entity.headYaw = player.getYaw();
float speedModifier = pokemon.isLegendary() ? 0.0f : (float) Cobblemounts.CONFIG.legendaryModifier;
float movementSpeed = player.getMovementSpeed() * (pokemon.getSpeed() / 12.0f) + speedModifier;
System.out.println(movementSpeed + ", " + Cobblemounts.CONFIG.cappedSpeed + ", "
+ Cobblemounts.CONFIG.speedCap);
if (Cobblemounts.CONFIG.cappedSpeed) {
if (movementSpeed >= Cobblemounts.CONFIG.speedCap) {
movementSpeed = (float) Cobblemounts.CONFIG.speedCap;
System.out.println(movementSpeed);
}
}
entity.setMovementSpeed(movementSpeed);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/cobblemounts.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cappedSpeed = true
speedCap = 0.15
speedCap = 0.5
flyingSpeedCap = 0.15 # 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
Expand Down

0 comments on commit 49234a4

Please sign in to comment.