优化歼灭者渲染

This commit is contained in:
Atsuishio 2025-05-02 00:12:19 +08:00 committed by Light_Quanta
parent 22568685a9
commit 8beccac565
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959
4 changed files with 1376 additions and 1343 deletions

View file

@ -5,13 +5,10 @@ import com.atsuishio.superbwarfare.config.server.VehicleConfig;
import com.atsuishio.superbwarfare.entity.vehicle.AnnihilatorEntity;
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Player;
import software.bernie.geckolib.animation.AnimationState;
import software.bernie.geckolib.cache.object.GeoBone;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.model.GeoModel;
import software.bernie.geckolib.model.data.EntityModelData;
import static com.atsuishio.superbwarfare.entity.vehicle.AnnihilatorEntity.*;
@ -46,10 +43,6 @@ public class AnnihilatorModel extends GeoModel<AnnihilatorEntity> {
@Override
public void setCustomAnimations(AnnihilatorEntity animatable, long instanceId, AnimationState<AnnihilatorEntity> animationState) {
GeoBone bone = getAnimationProcessor().getBone("PaoGuan");
EntityModelData entityData = animationState.getData(DataTickets.ENTITY_MODEL_DATA);
bone.setRotX((entityData.headPitch()) * Mth.DEG_TO_RAD);
GeoBone laserLeft = getAnimationProcessor().getBone("laser1");
GeoBone laserMiddle = getAnimationProcessor().getBone("laser2");
GeoBone laserRight = getAnimationProcessor().getBone("laser3");

View file

@ -5,13 +5,16 @@ import com.atsuishio.superbwarfare.client.model.entity.AnnihilatorModel;
import com.atsuishio.superbwarfare.entity.vehicle.AnnihilatorEntity;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import com.mojang.math.Axis;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.culling.Frustum;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.world.phys.AABB;
import software.bernie.geckolib.cache.object.BakedGeoModel;
import software.bernie.geckolib.cache.object.GeoBone;
import software.bernie.geckolib.renderer.GeoEntityRenderer;
public class AnnihilatorRenderer extends GeoEntityRenderer<AnnihilatorEntity> {
@ -41,14 +44,33 @@ public class AnnihilatorRenderer extends GeoEntityRenderer<AnnihilatorEntity> {
@Override
public void render(AnnihilatorEntity entityIn, float entityYaw, float partialTicks, PoseStack poseStack, MultiBufferSource bufferIn, int packedLightIn) {
poseStack.pushPose();
poseStack.mulPose(Axis.YP.rotationDegrees(-Mth.lerp(partialTicks, entityIn.yRotO, entityIn.getYRot())));
super.render(entityIn, entityYaw, partialTicks, poseStack, bufferIn, packedLightIn);
poseStack.popPose();
}
@Override
protected float getDeathMaxRotation(AnnihilatorEntity entityLivingBaseIn) {
return 0.0F;
public void renderRecursively(PoseStack poseStack, AnnihilatorEntity animatable, GeoBone bone, RenderType renderType, MultiBufferSource bufferSource, VertexConsumer buffer, boolean isReRender, float partialTick, int packedLight, int packedOverlay, int color) {
String name = bone.getName();
Minecraft minecraft = Minecraft.getInstance();
Frustum pCamera = minecraft.levelRenderer.getFrustum();
AABB aabb = animatable.getBoundingBoxForCulling().inflate(0.5);
if (aabb.hasNaN() || aabb.getSize() == 0.0) {
aabb = new AABB(animatable.getX() - 6.0, animatable.getY() - 4.0, animatable.getZ() - 6.0, animatable.getX() + 6.0, animatable.getY() + 4.0, animatable.getZ() + 6.0);
}
if (name.equals("bone")) {
bone.setHidden(!pCamera.isVisible(aabb));
}
if (name.equals("main") || name.equals("main2")) {
bone.setRotY(-Mth.lerp(partialTick, animatable.yRotO, animatable.getYRot()) * Mth.DEG_TO_RAD);
}
if (name.equals("PaoGuan") || name.equals("PaoGuan2")) {
bone.setRotX(-Mth.lerp(partialTick, animatable.xRotO, animatable.getXRot()) * Mth.DEG_TO_RAD);
}
super.renderRecursively(poseStack, animatable, bone, renderType, bufferSource, buffer, isReRender, partialTick, packedLight, packedOverlay, color);
}
}