Advertisement
CreativeMasterBonin

PurifyingVehicleModel class

Feb 17th, 2025
162
0
1 day
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.69 KB | None | 0 0
  1. package net.rk.addon.entity.model;
  2.  
  3. import com.mojang.blaze3d.vertex.PoseStack;
  4. import com.mojang.blaze3d.vertex.VertexConsumer;
  5. import net.minecraft.client.model.Model;
  6. import net.minecraft.client.model.geom.ModelLayerLocation;
  7. import net.minecraft.client.model.geom.ModelPart;
  8. import net.minecraft.client.model.geom.PartPose;
  9. import net.minecraft.client.model.geom.builders.*;
  10. import net.minecraft.client.renderer.RenderType;
  11. import net.minecraft.resources.ResourceLocation;
  12. import net.minecraft.util.Mth;
  13. import net.rk.addon.entity.PurifyingBoat;
  14.  
  15. public class PurifyingVehicleModel extends Model{
  16.     public static final ModelLayerLocation LAYER_LOCATION = new ModelLayerLocation(ResourceLocation.parse("thingamajigsgoodies:textures/entity/purifying_vehicle.png"), "main");
  17.  
  18.     private final ModelPart main;
  19.     private final ModelPart shooter;
  20.     private final ModelPart hoverfan;
  21.  
  22.     public PurifyingVehicleModel(ModelPart root) {
  23.         super(RenderType::entityTranslucent);
  24.         main = root.getChild("cockpit");
  25.         shooter = main.getChild("shooter");
  26.         hoverfan = main.getChild("hoverfan");
  27.     }
  28.  
  29.     public static LayerDefinition createBodyLayer() {
  30.         MeshDefinition meshdefinition = new MeshDefinition();
  31.         PartDefinition partdefinition = meshdefinition.getRoot();
  32.  
  33.         PartDefinition cockpit = partdefinition.addOrReplaceChild("cockpit", CubeListBuilder.create().texOffs(88, 0).addBox(-21.0F, -30.0F, -20.0F, 42.0F, 16.0F, 42.0F, new CubeDeformation(0.0F))
  34.                 .texOffs(0, 0).addBox(-16.0F, -1.0F, -16.0F, 32.0F, 1.0F, 32.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));
  35.  
  36.         PartDefinition northwall_r1 = cockpit.addOrReplaceChild("northwall_r1", CubeListBuilder.create().texOffs(160, 59).addBox(-16.0F, 13.0F, 8.0F, 32.0F, 1.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 1.0472F, 3.1416F, 0.0F));
  37.  
  38.         PartDefinition eastwall_r1 = cockpit.addOrReplaceChild("eastwall_r1", CubeListBuilder.create().texOffs(62, 59).addBox(-16.0F, 13.0F, 8.0F, 32.0F, 1.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 1.0472F, -1.5708F, 0.0F));
  39.  
  40.         PartDefinition southwall_r1 = cockpit.addOrReplaceChild("southwall_r1", CubeListBuilder.create().texOffs(160, 97).addBox(-16.0F, 13.0F, 8.0F, 32.0F, 1.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 1.0472F, 0.0F, 0.0F));
  41.  
  42.         PartDefinition westwall_r1 = cockpit.addOrReplaceChild("westwall_r1", CubeListBuilder.create().texOffs(160, 77).addBox(-16.0F, 13.0F, 8.0F, 32.0F, 1.0F, 16.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(0.0F, 0.0F, 0.0F, 1.0472F, 1.5708F, 0.0F));
  43.  
  44.         PartDefinition shooter = cockpit.addOrReplaceChild("shooter", CubeListBuilder.create().texOffs(0, 60).addBox(-7.0F, -2.0F, -12.0F, 4.0F, 4.0F, 16.0F, new CubeDeformation(0.0F))
  45.                 .texOffs(19, 37).addBox(3.0F, -2.0F, -12.0F, 4.0F, 4.0F, 16.0F, new CubeDeformation(0.0F))
  46.                 .texOffs(0, 102).addBox(-8.0F, -5.0F, 2.0F, 16.0F, 8.0F, 8.0F, new CubeDeformation(0.0F)), PartPose.offset(-1.0F, 20.0F, -24.0F));
  47.  
  48.         PartDefinition hoverfan = cockpit.addOrReplaceChild("hoverfan", CubeListBuilder.create().texOffs(0, 36).addBox(-5.0F, 0.0F, -3.0F, 8.0F, 4.0F, 8.0F, new CubeDeformation(0.0F))
  49.                 .texOffs(0, 85).addBox(-17.0F, 2.0F, -1.0F, 32.0F, 1.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offset(0.0F, 24.0F, 0.0F));
  50.  
  51.         PartDefinition blade2_r1 = hoverfan.addOrReplaceChild("blade2_r1", CubeListBuilder.create().texOffs(0, 93).addBox(-16.0F, -1.5F, -2.0F, 32.0F, 1.0F, 4.0F, new CubeDeformation(0.0F)), PartPose.offsetAndRotation(-1.0F, 2.5F, 1.0F, 0.0F, -1.5708F, 0.0F));
  52.  
  53.         return LayerDefinition.create(meshdefinition, 256, 128);
  54.     }
  55.  
  56.     public void setupAnim(PurifyingBoat boat){
  57.         main.y = -1.0f;
  58.         hoverfan.y = main.y + 2.25f;
  59.         shooter.y = main.y - 1.0f;
  60.  
  61.         if(hoverfan.yRot > 360){
  62.             hoverfan.yRot = 0;
  63.         }
  64.         else{
  65.             hoverfan.yRot += 0.02f * Mth.clamp((float)(boat.getDeltaMovement().x + boat.getDeltaMovement().z),-10,10);
  66.         }
  67.  
  68.         if(boat.isDrilling){
  69.             shooter.xRot = 3.14f;
  70.         }
  71.         else{
  72.             shooter.xRot = 0;
  73.         }
  74.  
  75.         if(boat.fireButton){
  76.             shooter.z = -25f - ((float)Mth.cos(boat.tickCount) * 2.0F);
  77.         }
  78.         else{
  79.             shooter.z = -25f;
  80.         }
  81.  
  82.  
  83.         main.xRot = 3.14555111f;
  84.     }
  85.  
  86.     @Override
  87.     public void renderToBuffer(PoseStack poseStack, VertexConsumer vertexConsumer, int i, int i1, int i2) {
  88.         main.render(poseStack, vertexConsumer, i,i1,i2);
  89.     }
  90. }
  91.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement