Advertisement
Guest User

MCreator Iron Bow Renderer.java

a guest
Jan 16th, 2024
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. package net.mcreator.smithingplusmod.entity.renderer;
  2.  
  3. import net.minecraftforge.fml.client.registry.RenderingRegistry;
  4. import net.minecraftforge.eventbus.api.SubscribeEvent;
  5. import net.minecraftforge.client.event.ModelRegistryEvent;
  6. import net.minecraftforge.api.distmarker.OnlyIn;
  7. import net.minecraftforge.api.distmarker.Dist;
  8.  
  9. import net.minecraft.util.math.vector.Vector3f;
  10. import net.minecraft.util.math.MathHelper;
  11. import net.minecraft.util.ResourceLocation;
  12. import net.minecraft.entity.Entity;
  13. import net.minecraft.client.renderer.texture.OverlayTexture;
  14. import net.minecraft.client.renderer.model.ModelRenderer;
  15. import net.minecraft.client.renderer.entity.model.EntityModel;
  16. import net.minecraft.client.renderer.entity.EntityRenderer;
  17. import net.minecraft.client.renderer.entity.ArrowRenderer;
  18. import net.minecraft.client.renderer.RenderType;
  19. import net.minecraft.client.renderer.IRenderTypeBuffer;
  20.  
  21. import net.mcreator.smithingplusmod.item.IronBowItem;
  22.  
  23. import com.mojang.blaze3d.vertex.IVertexBuilder;
  24. import com.mojang.blaze3d.matrix.MatrixStack;
  25.  
  26. @OnlyIn(Dist.CLIENT)
  27. public class IronBowRenderer {
  28. public static class ModelRegisterHandler {
  29. @SubscribeEvent
  30. @OnlyIn(Dist.CLIENT)
  31. public void registerModels(ModelRegistryEvent event) {
  32. RenderingRegistry.registerEntityRenderingHandler(IronBowItem.arrow, renderManager -> new CustomRender(renderManager));
  33. }
  34. }
  35.  
  36. @OnlyIn(Dist.CLIENT)
  37. public class IronArrowRenderer extends ArrowRenderer<IronArrowEntity> {
  38. private static final ResourceLocation texture = new ResourceLocation("smithingplusmod:textures/entities/iron_arrow.png");
  39.  
  40. public IronArrowRenderer(EntityRenderer.Context context) {
  41. super(context);
  42. }
  43.  
  44. @Override
  45. public ResourceLocation getTextureLocation(IronArrowEntity entity) {
  46. return texture;
  47. }
  48. }
  49.  
  50. @Override
  51. public void render(IronBowItem.ArrowCustomEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn,
  52. IRenderTypeBuffer bufferIn, int packedLightIn) {
  53. IVertexBuilder vb = bufferIn.getBuffer(RenderType.getEntityCutout(this.getEntityTexture(entityIn)));
  54. matrixStackIn.push();
  55. matrixStackIn.rotate(Vector3f.YP.rotationDegrees(MathHelper.lerp(partialTicks, entityIn.prevRotationYaw, entityIn.rotationYaw) - 90));
  56. matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(90 + MathHelper.lerp(partialTicks, entityIn.prevRotationPitch, entityIn.rotationPitch)));
  57. EntityModel model = new ModelIron_Arrow();
  58. model.render(matrixStackIn, vb, packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 0.0625f);
  59. matrixStackIn.pop();
  60. super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
  61. }
  62.  
  63. @Override
  64. public ResourceLocation getEntityTexture(IronBowItem.ArrowCustomEntity entity) {
  65. return texture;
  66. }
  67. }
  68.  
  69. // Made with Blockbench 4.9.3
  70. // Exported for Minecraft version 1.15 - 1.16 with Mojang mappings
  71. // Paste this class into your mod and generate all required imports
  72. public static class ModelIron_Arrow {
  73. java.extends;EntityModel<Entity>()
  74. {
  75. public static ModelRenderer ; Layer1;
  76. public static ModelRenderer ; layer2;
  77. public static ModelRenderer ; cube_r1;
  78. public static ModelRenderer ; cube_r2;public static ModelIron_Arrow
  79. { -> ;
  80. {
  81. texWidth = 32;
  82. texHeight = 32;
  83. Layer1 = new ModelRenderer(this);
  84. Layer1.setPos(0.0F, 24.0F, 0.0F);
  85. Layer1.texOffs(0, -14).addBox(0.0F, -8.0F, -8.0F, 0.0F, 1.0F, 16.0F, 0.0F, false);
  86. Layer1.texOffs(13, -1).addBox(0.0F, -9.0F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
  87. Layer1.texOffs(13, 1).addBox(0.0F, -7.0F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
  88. Layer1.texOffs(1, 0).addBox(0.0F, -7.0F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  89. Layer1.texOffs(0, 1).addBox(0.0F, -6.0F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  90. Layer1.texOffs(1, -2).addBox(0.0F, -9.0F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  91. Layer1.texOffs(0, -3).addBox(0.0F, -10.0F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  92. layer2 = new ModelRenderer(this);
  93. layer2.setPos(0.0F, 24.0F, 0.0F);
  94. cube_r1 = new ModelRenderer(this);
  95. cube_r1.setPos(0.0F, 0.0F, 0.0F);
  96. layer2.addChild(cube_r1);
  97. setRotationAngle(cube_r1, 0.0F, 0.0F, -1.5708F);
  98. cube_r1.texOffs(0, 1).addBox(7.5F, 1.5F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  99. cube_r1.texOffs(1, 0).addBox(7.5F, 0.5F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  100. cube_r1.texOffs(0, 1).addBox(7.5F, -2.5F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  101. cube_r1.texOffs(1, 0).addBox(7.5F, -1.5F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
  102. cube_r1.texOffs(13, 1).addBox(7.5F, -1.5F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
  103. cube_r1.texOffs(13, -1).addBox(7.5F, 0.51F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
  104. cube_r2 = new ModelRenderer(this);
  105. cube_r2.setPos(0.0F, 0.0F, 0.0F);
  106. layer2.addChild(cube_r2);
  107. setRotationAngle(cube_r2, 0.0F, 0.0F, 1.5708F);
  108. cube_r2.texOffs(0, -14).addBox(-7.5F, -0.5F, -8.0F, 0.0F, 1.0F, 16.0F, 0.0F, false);
  109. }
  110.  
  111. @Override
  112. public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
  113. float alpha) {
  114. Layer1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
  115. layer2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
  116. }
  117.  
  118. public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
  119. modelRenderer.xRot = x;
  120. modelRenderer.yRot = y;
  121. modelRenderer.zRot = z;
  122. }
  123.  
  124. public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
  125. this.layer2.yRot = headPitch / (180F / (float) Math.PI);
  126. this.cube_r1.xRot = headPitch / (180F / (float) Math.PI);
  127. this.cube_r2.yRot = netHeadYaw / (180F / (float) Math.PI);
  128. this.Layer1.xRot = headPitch / (180F / (float) Math.PI);
  129. }
  130. }
  131. }
  132. }
Tags: #MCreator
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement