Skip to content

Commit

Permalink
fixed some rubber banding i think
Browse files Browse the repository at this point in the history
  • Loading branch information
IoIxD committed Oct 25, 2023
1 parent c84a51e commit dc159ab
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/net/ioixd/mixin/PlayerMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
import com.cobblemon.mod.common.entity.PoseType;
import com.cobblemon.mod.common.client.render.models.blockbench.repository.PokemonModelRepository;

import java.util.concurrent.atomic.AtomicBoolean;

@Mixin(PlayerEntity.class)
public class PlayerMixin {
int ticksInLiquid = 0;
Expand All @@ -50,6 +52,7 @@ private void travel(Vec3d movement, CallbackInfo info) {
boolean inLiquid = water instanceof FluidBlock;

float speedModifier = pokemon.isLegendary() ? 0.0f : 0.05f;
AtomicBoolean isFlying = new AtomicBoolean(false);

pokemon.getTypes().forEach(ty -> {
switch(ty.getName()) {
Expand All @@ -60,9 +63,7 @@ private void travel(Vec3d movement, CallbackInfo info) {
living.updateVelocity((pokemon.getSpeed() / 500.0f) + speedModifier,
player.getRotationVector());
living.move(MovementType.SELF, living.getVelocity());
if (living.horizontalCollision) {
living.teleport(lastPos.x, lastPos.y, lastPos.z);
}
isFlying.set(true);
}
living.setPose(EntityPose.SWIMMING);
} else {
Expand All @@ -76,6 +77,7 @@ private void travel(Vec3d movement, CallbackInfo info) {
living.updateVelocity((pokemon.getSpeed() / 500.0f) + speedModifier,
player.getRotationVector());
living.move(MovementType.SELF, living.getVelocity());
isFlying.set(true);
}
living.setPose(EntityPose.FALL_FLYING);
living.setBehaviourFlag(PokemonBehaviourFlag.FLYING, true);
Expand All @@ -87,7 +89,9 @@ private void travel(Vec3d movement, CallbackInfo info) {
}
});
if (movement.z > 0.0) {
living.travel(player.getRotationVector());
if (!isFlying.get()) {
living.travel(player.getRotationVector());
}
World world = living.getWorld();
BlockPos forwardPos = switch (player.getMovementDirection()) {
case NORTH -> living.getBlockPos().north();
Expand Down

0 comments on commit dc159ab

Please sign in to comment.