com.parzivail.util.client.model.ModelUtil Maven / Gradle / Ivy
package com.parzivail.util.client.model;
import org.joml.Vector3f;
import java.util.Collection;
import java.util.Optional;
import net.minecraft.class_1306;
import net.minecraft.class_1309;
import net.minecraft.class_238;
import net.minecraft.class_243;
import net.minecraft.class_3532;
import net.minecraft.class_572;
import net.minecraft.class_630;
public class ModelUtil
{
public static Optional getChild(class_630 root, String name)
{
if (root.method_41919(name))
return Optional.of(root.method_32086(name));
return Optional.empty();
}
public static void smartLerpArmsRadians(T entity, class_572> model, float delta, float leftPitch, float leftYaw, float leftRoll, float rightPitch, float rightYaw, float rightRoll)
{
class_630 leftArm = model.field_27433;
class_630 rightArm = model.field_3401;
if (entity.method_6068() == class_1306.field_6182)
{
rightYaw = -rightYaw;
rightRoll = -rightRoll;
leftYaw = -leftYaw;
leftRoll = -leftRoll;
leftArm = model.field_3401;
rightArm = model.field_27433;
}
rightArm.field_3654 = class_3532.method_16439(delta, rightArm.field_3654, rightPitch);
rightArm.field_3675 = class_3532.method_16439(delta, rightArm.field_3675, rightYaw);
rightArm.field_3674 = class_3532.method_16439(delta, rightArm.field_3674, rightRoll);
leftArm.field_3654 = class_3532.method_16439(delta, leftArm.field_3654, leftPitch);
leftArm.field_3675 = class_3532.method_16439(delta, leftArm.field_3675, leftYaw);
leftArm.field_3674 = class_3532.method_16439(delta, leftArm.field_3674, leftRoll);
}
public static void lerpLeftArmToDegrees(class_572 model, float delta, float pitch, float yaw, float roll)
{
model.field_27433.field_3654 = class_3532.method_17821(delta, model.field_27433.field_3654 * class_3532.field_29848, pitch * class_3532.field_29848) * class_3532.field_29847;
model.field_27433.field_3675 = class_3532.method_17821(delta, model.field_27433.field_3675 * class_3532.field_29848, yaw * class_3532.field_29848) * class_3532.field_29847;
model.field_27433.field_3674 = class_3532.method_17821(delta, model.field_27433.field_3674 * class_3532.field_29848, roll * class_3532.field_29848) * class_3532.field_29847;
}
public static void lerpRightArmToDegrees(class_572 model, float delta, float pitch, float yaw, float roll)
{
model.field_3401.field_3654 = class_3532.method_17821(delta, model.field_3401.field_3654 * class_3532.field_29848, pitch * class_3532.field_29848) * class_3532.field_29847;
model.field_3401.field_3675 = class_3532.method_17821(delta, model.field_3401.field_3675 * class_3532.field_29848, yaw * class_3532.field_29848) * class_3532.field_29847;
model.field_3401.field_3674 = class_3532.method_17821(delta, model.field_3401.field_3674 * class_3532.field_29848, roll * class_3532.field_29848) * class_3532.field_29847;
}
public static class_238 getBounds(Collection verts)
{
var min = new Vector3f(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
var max = new Vector3f(Float.MIN_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
for (var v : verts)
{
if (v.x < min.x)
min.set(v.x, min.y, min.z);
if (v.y < min.y)
min.set(min.x, v.y, min.z);
if (v.z < min.z)
min.set(min.x, min.y, v.z);
if (v.x > max.x)
max.set(v.x, max.y, max.z);
if (v.y > max.y)
max.set(max.x, v.y, max.z);
if (v.z > max.z)
max.set(max.x, max.y, v.z);
}
return new class_238(new class_243(min), new class_243(max));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy