changed rotation of orbs and discs based on their heading

This commit is contained in:
luisc committed 2026-02-23 16:15:43 -06:00
1 parent 0a85bb5a7b
commit fcbd2545cb
3 files changed
+48

No files matched your search

@@ -4,6 +4,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.entity.EntityAbilityDisc;
import net.minecraft.entity.Entity;
import net.minecraft.util.Vec3;
import noppes.npcs.util.MathUtil;
import org.lwjgl.opengl.GL11;
/**
@@ -51,6 +53,16 @@ public class RenderAbilityDisc extends RenderEnergyAbility {
GL11.glRotatef(90.0f, 1.0f, 0.0f, 0.0f);
}
double motionX = entity.motionX;
double motionY = entity.motionY;
double motionZ = entity.motionZ;
Vec3 motionVec = Vec3.createVectorHelper(motionX, motionY, motionZ);
float motionYaw = MathUtil.getYaw(motionVec);
float motionPitch = MathUtil.getPitch(motionVec);
GL11.glRotatef(motionYaw, 0, 1, 0);
GL11.glRotatef(motionPitch, 1, 0, 0);
// Apply Y-axis rotation for spin
GL11.glRotatef(disc.getInterpolatedRotationY(partialTicks), 0.0f, 1.0f, 0.0f);
@@ -4,6 +4,8 @@ import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import kamkeel.npcs.entity.EntityAbilityOrb;
import net.minecraft.entity.Entity;
import net.minecraft.util.Vec3;
import noppes.npcs.util.MathUtil;
import org.lwjgl.opengl.GL11;
/**
@@ -37,6 +39,16 @@ public class RenderAbilityOrb extends RenderEnergyAbility {
renderAttachedLightning(orb, 0.6f * 0.5f, scale);
}
double motionX = entity.motionX;
double motionY = entity.motionY;
double motionZ = entity.motionZ;
Vec3 motionVec = Vec3.createVectorHelper(motionX, motionY, motionZ);
float motionYaw = MathUtil.getYaw(motionVec);
float motionPitch = MathUtil.getPitch(motionVec);
GL11.glRotatef(motionYaw, 0, 1, 0);
GL11.glRotatef(motionPitch, 1, 0, 0);
// Use entity's interpolated rotation for smooth spinning
GL11.glRotatef(orb.getInterpolatedRotationX(partialTicks), 1.0f, 0.0f, 0.0f);
GL11.glRotatef(orb.getInterpolatedRotationY(partialTicks), 0.0f, 1.0f, 0.0f);
@@ -0,0 +1,24 @@
package noppes.npcs.util;
import net.minecraft.util.Vec3;
public class MathUtil {
public static float getYaw(Vec3 vector) {
double x = vector.xCoord;
double z = vector.zCoord;
double yawRad = Math.atan2(z, x);
return 90F - (float) Math.toDegrees(yawRad);
}
public static float getPitch(Vec3 vector) {
double x = vector.xCoord;
double y = vector.yCoord;
double z = vector.zCoord;
double horizontalMag = Math.sqrt(x * x + z * z);
double pitchRad = Math.atan2(y, horizontalMag);
return (float) -Math.toDegrees(pitchRad);
}
}