Skip to content

Commit

Permalink
feat(game.entity): method for getting entity facing 8-wind direction
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Oct 27, 2022
1 parent 06bcf3e commit e549bad
Showing 1 changed file with 9 additions and 0 deletions.
@@ -1,8 +1,11 @@
package org.auioc.mcmod.arnicalib.game.entity;

import org.auioc.mcmod.arnicalib.game.chat.TextUtils;
import org.auioc.mcmod.arnicalib.game.world.LevelUtils;
import net.minecraft.core.Vec3i;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -36,4 +39,10 @@ public static double calcSpeed(Entity entity) {
return calcVelocity(entity).length();
}

public static Component getFacing8WindDirection(Entity entity) {
float yaw = Mth.wrapDegrees(entity.getYRot());
int d8 = (int) Math.floor((yaw - 180.0F) / 45.0F + 0.5F) & 7;
return TextUtils.translatable("direction.8wind." + d8);
}

}

0 comments on commit e549bad

Please sign in to comment.