Skip to content

Commit

Permalink
minor optimisations + better camera rotate
Browse files Browse the repository at this point in the history
  • Loading branch information
CammiePone committed Oct 18, 2021
1 parent 2e65055 commit e1bf35c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 11 additions & 4 deletions src/main/java/dev/cammiescorner/icarus/common/items/WingItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ public WingType getWingType() {

public void stopFlying(PlayerEntity player) {
shouldSlowfall = true;

if(player.getPitch() < -90 || player.getPitch() > 90) {
float offset = (player.getPitch() < -90 ? player.getPitch() + 180 : player.getPitch() - 180) * 2;
player.setPitch((player.getPitch() < -90 ? 180 + offset : -180 - offset) + player.getPitch());
player.setYaw(180 + player.getYaw());
}

player.stopFallFlying();
}

Expand All @@ -121,11 +128,11 @@ public void applySpeed(PlayerEntity player) {
Vec3d rotation = player.getRotationVector();
Vec3d velocity = player.getVelocity();
float modifier = Icarus.getConfig().armourSlows ? Math.max(1F, (player.getArmor() / 30F) * Icarus.getConfig().maxSlowedMultiplier) : 1F;
System.out.println(modifier);
float speed = Icarus.getConfig().wingsSpeed / modifier;

player.setVelocity(velocity.add(rotation.x * (Icarus.getConfig().wingsSpeed / modifier) + (rotation.x * 1.5D - velocity.x) * (Icarus.getConfig().wingsAcceleration / modifier),
rotation.y * (Icarus.getConfig().wingsSpeed / modifier) + (rotation.y * 1.5D - velocity.y) * (Icarus.getConfig().wingsAcceleration / modifier),
rotation.z * (Icarus.getConfig().wingsSpeed / modifier) + (rotation.z * 1.5D - velocity.z) * (Icarus.getConfig().wingsAcceleration / modifier)));
player.setVelocity(velocity.add(rotation.x * speed + (rotation.x * 1.5D - velocity.x) * speed,
rotation.y * speed + (rotation.y * 1.5D - velocity.y) * speed,
rotation.z * speed + (rotation.z * 1.5D - velocity.z) * speed));

if(!FREE_FLIGHT.contains(this) && !player.isCreative())
DeleteHungerMessage.send();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class IcarusConfig implements ConfigData {
public boolean armourSlows = true;
public float maxSlowedMultiplier = 3F;
public float wingsSpeed = 0.025F;
public float wingsAcceleration = 0.025F;
public int wingsDurability = 432;
public float exhaustionAmount = 0.03F;
public float rollAmount = 1.0F;
Expand Down

0 comments on commit e1bf35c

Please sign in to comment.