86 lines
4.6 KiB
Java
86 lines
4.6 KiB
Java
package com.dairymoose.entity;
|
|
|
|
import com.dairymoose.entity.MotorboatEntity;
|
|
import com.mojang.blaze3d.vertex.PoseStack;
|
|
import com.mojang.blaze3d.vertex.VertexConsumer;
|
|
import com.mojang.math.Vector3f;
|
|
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.EntityRenderer;
|
|
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
|
import net.minecraft.core.particles.ParticleTypes;
|
|
import net.minecraft.resources.ResourceLocation;
|
|
import net.minecraft.util.Mth;
|
|
import net.minecraft.world.entity.Entity;
|
|
import net.minecraft.world.phys.Vec3;
|
|
import net.minecraftforge.api.distmarker.Dist;
|
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
|
import org.apache.logging.log4j.LogManager;
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
@OnlyIn(Dist.CLIENT)
|
|
/* loaded from: outputsrg.jar:com/dairymoose/entity/MotorboatRenderer.class */
|
|
public final class MotorboatRenderer extends EntityRenderer<MotorboatEntity> {
|
|
private float modelScale;
|
|
private final MotorboatModel motorboatModel;
|
|
private static final Logger LOGGER = LogManager.getLogger();
|
|
private static final ResourceLocation texture = new ResourceLocation("modernlife", "textures/entity/motorboat_uv.png");
|
|
|
|
public MotorboatRenderer(EntityRendererProvider.Context ctx) {
|
|
super(ctx);
|
|
this.modelScale = 1.0f;
|
|
this.motorboatModel = new MotorboatModel(ctx.bakeLayer(MotorboatModel.MOTORBOAT));
|
|
}
|
|
|
|
public boolean shouldRender(MotorboatEntity p_225626_1_, Frustum p_225626_2_, double p_225626_3_, double p_225626_5_, double p_225626_7_) {
|
|
return true;
|
|
}
|
|
|
|
public void render(MotorboatEntity motorboatEntity, float p_225623_2_, float p_225623_3_, PoseStack matrixStack, MultiBufferSource buffer, int p_225623_6_) {
|
|
motorboatEntity.position();
|
|
matrixStack.pushPose();
|
|
matrixStack.translate(0.0d, 1.5d, 0.0d);
|
|
matrixStack.mulPose(Vector3f.YP.rotationDegrees(270.0f - p_225623_2_));
|
|
float lvt_7_1_ = motorboatEntity.getHurtTime() - p_225623_3_;
|
|
float lvt_8_1_ = motorboatEntity.getDamage() - p_225623_3_;
|
|
if (lvt_8_1_ < 0.0f) {
|
|
lvt_8_1_ = 0.0f;
|
|
}
|
|
if (lvt_7_1_ > 0.0f) {
|
|
matrixStack.mulPose(Vector3f.XP.rotationDegrees((((Mth.sin(lvt_7_1_) * lvt_7_1_) * lvt_8_1_) / 10.0f) * motorboatEntity.getHurtDir()));
|
|
}
|
|
matrixStack.scale(-this.modelScale, -this.modelScale, this.modelScale);
|
|
this.motorboatModel.setupAnim(motorboatEntity, p_225623_3_, 0.0f, -0.1f, 0.0f, 0.0f);
|
|
VertexConsumer builder = buffer.getBuffer(this.motorboatModel.m_103119_(getTextureLocation(motorboatEntity)));
|
|
this.motorboatModel.m_7695_(matrixStack, builder, p_225623_6_, OverlayTexture.NO_OVERLAY, 1.0f, 1.0f, 1.0f, 1.0f);
|
|
if (!motorboatEntity.isUnderWater()) {
|
|
VertexConsumer vertexconsumer1 = buffer.getBuffer(RenderType.waterMask());
|
|
this.motorboatModel.waterPatch().render(matrixStack, vertexconsumer1, p_225623_6_, OverlayTexture.NO_OVERLAY);
|
|
}
|
|
matrixStack.popPose();
|
|
Entity controller = motorboatEntity.getControllingPassenger();
|
|
if (controller != null && motorboatEntity.tickCount % 2 == 0 && motorboatEntity.status == MotorboatEntity.Status.IN_WATER && !motorboatEntity.isOutOfFuel()) {
|
|
Vec3 vec3 = new Vec3(1.65d, 0.45d, 0.0d).yRot(-((motorboatEntity.getYRot() * 0.017453292f) - 1.5707964f));
|
|
Vec3 particleLocation = motorboatEntity.position().add(vec3);
|
|
int count = 1;
|
|
if (!motorboatEntity.isBackingUp() && motorboatEntity.getDeltaMovement().lengthSqr() > 0.0144d) {
|
|
float accelPct = motorboatEntity.getCurAccel() / motorboatEntity.getMaxAccel();
|
|
count = Math.max(1, (int) Math.ceil(12 * accelPct));
|
|
}
|
|
for (int i = 0; i < count; i++) {
|
|
double xRand = ((Math.random() * 2.0d) * 0.6d) - 0.6d;
|
|
double yRand = ((Math.random() * 2.0d) * 0.3d) - 0.3d;
|
|
double zRand = ((Math.random() * 2.0d) * 0.6d) - 0.6d;
|
|
motorboatEntity.level.addParticle(ParticleTypes.SPLASH, particleLocation.x - xRand, particleLocation.y + yRand, particleLocation.z + zRand, 1.0d, 1.0d, 1.0d);
|
|
}
|
|
}
|
|
super.render(motorboatEntity, p_225623_2_, p_225623_3_, matrixStack, buffer, p_225623_6_);
|
|
}
|
|
|
|
public ResourceLocation getTextureLocation(MotorboatEntity var1) {
|
|
return texture;
|
|
}
|
|
}
|