Skip to content

Commit

Permalink
feat(game.entity): method for getting axolotl variant display name
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Oct 27, 2022
1 parent e549bad commit d2211d3
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.resources.ResourceKey;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.animal.axolotl.Axolotl;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.Vec3;

Expand All @@ -28,6 +29,7 @@ public static void teleportTo(Entity entity, ResourceKey<Level> dim, Vec3i pos)
entity.changeDimension(LevelUtils.getLevel(dim), LevelUtils.createSimpleTeleporter(pos));
}


public static Vec3 calcVelocity(Entity entity) {
double vX = entity.getX() - entity.xOld;
double vY = entity.getY() - entity.yOld;
Expand All @@ -39,10 +41,16 @@ 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);
}


public static Component getAxolotlVariantName(Axolotl.Variant variant) {
return TextUtils.translatable("entity.minecraft.axolotl.variant." + variant.getName());
}

}

0 comments on commit d2211d3

Please sign in to comment.