Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.smithingplusmod.entity.renderer;
- import net.minecraftforge.fml.client.registry.RenderingRegistry;
- import net.minecraftforge.eventbus.api.SubscribeEvent;
- import net.minecraftforge.client.event.ModelRegistryEvent;
- import net.minecraftforge.api.distmarker.OnlyIn;
- import net.minecraftforge.api.distmarker.Dist;
- import net.minecraft.util.math.vector.Vector3f;
- import net.minecraft.util.math.MathHelper;
- import net.minecraft.util.ResourceLocation;
- import net.minecraft.entity.Entity;
- import net.minecraft.client.renderer.texture.OverlayTexture;
- import net.minecraft.client.renderer.model.ModelRenderer;
- import net.minecraft.client.renderer.entity.model.EntityModel;
- import net.minecraft.client.renderer.entity.EntityRenderer;
- import net.minecraft.client.renderer.entity.ArrowRenderer;
- import net.minecraft.client.renderer.RenderType;
- import net.minecraft.client.renderer.IRenderTypeBuffer;
- import net.mcreator.smithingplusmod.item.IronBowItem;
- import com.mojang.blaze3d.vertex.IVertexBuilder;
- import com.mojang.blaze3d.matrix.MatrixStack;
- @OnlyIn(Dist.CLIENT)
- public class IronBowRenderer {
- public static class ModelRegisterHandler {
- @SubscribeEvent
- @OnlyIn(Dist.CLIENT)
- public void registerModels(ModelRegistryEvent event) {
- RenderingRegistry.registerEntityRenderingHandler(IronBowItem.arrow, renderManager -> new CustomRender(renderManager));
- }
- }
- @OnlyIn(Dist.CLIENT)
- public class IronArrowRenderer extends ArrowRenderer<IronArrowEntity> {
- private static final ResourceLocation texture = new ResourceLocation("smithingplusmod:textures/entities/iron_arrow.png");
- public IronArrowRenderer(EntityRenderer.Context context) {
- super(context);
- }
- @Override
- public ResourceLocation getTextureLocation(IronArrowEntity entity) {
- return texture;
- }
- }
- @Override
- public void render(IronBowItem.ArrowCustomEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn,
- IRenderTypeBuffer bufferIn, int packedLightIn) {
- IVertexBuilder vb = bufferIn.getBuffer(RenderType.getEntityCutout(this.getEntityTexture(entityIn)));
- matrixStackIn.push();
- matrixStackIn.rotate(Vector3f.YP.rotationDegrees(MathHelper.lerp(partialTicks, entityIn.prevRotationYaw, entityIn.rotationYaw) - 90));
- matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(90 + MathHelper.lerp(partialTicks, entityIn.prevRotationPitch, entityIn.rotationPitch)));
- EntityModel model = new ModelIron_Arrow();
- model.render(matrixStackIn, vb, packedLightIn, OverlayTexture.NO_OVERLAY, 1, 1, 1, 0.0625f);
- matrixStackIn.pop();
- super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn);
- }
- @Override
- public ResourceLocation getEntityTexture(IronBowItem.ArrowCustomEntity entity) {
- return texture;
- }
- }
- // Made with Blockbench 4.9.3
- // Exported for Minecraft version 1.15 - 1.16 with Mojang mappings
- // Paste this class into your mod and generate all required imports
- public static class ModelIron_Arrow {
- java.extends;EntityModel<Entity>()
- {
- public static ModelRenderer ; Layer1;
- public static ModelRenderer ; layer2;
- public static ModelRenderer ; cube_r1;
- public static ModelRenderer ; cube_r2;public static ModelIron_Arrow
- { -> ;
- {
- texWidth = 32;
- texHeight = 32;
- Layer1 = new ModelRenderer(this);
- Layer1.setPos(0.0F, 24.0F, 0.0F);
- Layer1.texOffs(0, -14).addBox(0.0F, -8.0F, -8.0F, 0.0F, 1.0F, 16.0F, 0.0F, false);
- Layer1.texOffs(13, -1).addBox(0.0F, -9.0F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
- Layer1.texOffs(13, 1).addBox(0.0F, -7.0F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
- Layer1.texOffs(1, 0).addBox(0.0F, -7.0F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- Layer1.texOffs(0, 1).addBox(0.0F, -6.0F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- Layer1.texOffs(1, -2).addBox(0.0F, -9.0F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- Layer1.texOffs(0, -3).addBox(0.0F, -10.0F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- layer2 = new ModelRenderer(this);
- layer2.setPos(0.0F, 24.0F, 0.0F);
- cube_r1 = new ModelRenderer(this);
- cube_r1.setPos(0.0F, 0.0F, 0.0F);
- layer2.addChild(cube_r1);
- setRotationAngle(cube_r1, 0.0F, 0.0F, -1.5708F);
- cube_r1.texOffs(0, 1).addBox(7.5F, 1.5F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- cube_r1.texOffs(1, 0).addBox(7.5F, 0.5F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- cube_r1.texOffs(0, 1).addBox(7.5F, -2.5F, 5.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- cube_r1.texOffs(1, 0).addBox(7.5F, -1.5F, 4.0F, 0.0F, 1.0F, 3.0F, 0.0F, false);
- cube_r1.texOffs(13, 1).addBox(7.5F, -1.5F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
- cube_r1.texOffs(13, -1).addBox(7.5F, 0.51F, -7.0F, 0.0F, 1.0F, 2.0F, 0.0F, false);
- cube_r2 = new ModelRenderer(this);
- cube_r2.setPos(0.0F, 0.0F, 0.0F);
- layer2.addChild(cube_r2);
- setRotationAngle(cube_r2, 0.0F, 0.0F, 1.5708F);
- cube_r2.texOffs(0, -14).addBox(-7.5F, -0.5F, -8.0F, 0.0F, 1.0F, 16.0F, 0.0F, false);
- }
- @Override
- public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue,
- float alpha) {
- Layer1.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
- layer2.render(matrixStack, buffer, packedLight, packedOverlay, red, green, blue, alpha);
- }
- public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
- modelRenderer.xRot = x;
- modelRenderer.yRot = y;
- modelRenderer.zRot = z;
- }
- public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
- this.layer2.yRot = headPitch / (180F / (float) Math.PI);
- this.cube_r1.xRot = headPitch / (180F / (float) Math.PI);
- this.cube_r2.yRot = netHeadYaw / (180F / (float) Math.PI);
- this.Layer1.xRot = headPitch / (180F / (float) Math.PI);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement