Posted August 22, 20214 yr I am trying to mod that adds boomerangs, but whenever I try to make the entity rotate nothing happens. plz help
August 22, 20214 yr Author package me.oreobean.boomerang.entities; import me.oreobean.boomerang.registries.EntityRegistry; import net.minecraft.entity.EntityType; import net.minecraft.nbt.CompoundNBT; import net.minecraft.network.IPacket; import net.minecraft.world.World; import net.minecraftforge.fml.network.FMLPlayMessages; import net.minecraftforge.fml.network.NetworkHooks; public class WoodBoomerangEntity extends AbstractBoomerangEntity{ public WoodBoomerangEntity(EntityType<? extends WoodBoomerangEntity> type, World world){ super(type, world); } public void registerData(){ } @Override protected void readAdditional(CompoundNBT compound) { } @Override protected void writeAdditional(CompoundNBT compound) { } public IPacket<?> createSpawnPacket(){ return NetworkHooks.getEntitySpawningPacket(this); } public WoodBoomerangEntity(FMLPlayMessages.SpawnEntity packet, World worldIn){ super(EntityRegistry.WOOD_BOOMERANG_ENTITY.get(), worldIn); } public WoodBoomerangEntity(EntityType<? extends WoodBoomerangEntity> type, double x, double y, double z, World world){ super(EntityRegistry.WOOD_BOOMERANG_ENTITY.get(), world); } @Override public void tick() { super.tick(); this.setPositionAndRotation(this.getPosX(), this.getPosY(), this.getPosZ(), 20,20); System.out.println(this.getRotationYawHead()); } } Entity code Edited August 22, 20214 yr by OreoBean
August 22, 20214 yr Author package me.oreobean.boomerang.client.renderers; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import me.oreobean.boomerang.Main; import me.oreobean.boomerang.client.models.WoodBoomerangModel; import me.oreobean.boomerang.entities.WoodBoomerangEntity; import net.minecraft.client.renderer.IRenderTypeBuffer; import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.client.renderer.entity.EntityRendererManager; import net.minecraft.client.renderer.texture.OverlayTexture; import net.minecraft.entity.passive.horse.AbstractHorseEntity; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.client.registry.IRenderFactory; import javax.sound.midi.Receiver; public class WoodBoomerangRenderer extends EntityRenderer<WoodBoomerangEntity> { private static ResourceLocation TEXTURE = new ResourceLocation(Main.MOD_ID, "textures/entity/wood_boomerang.png"); private final WoodBoomerangModel<WoodBoomerangEntity> MODEL = new WoodBoomerangModel<>(); public WoodBoomerangRenderer(EntityRendererManager manager){ super(manager); } public ResourceLocation getEntityTexture(WoodBoomerangEntity entity){ return TEXTURE; } public void render(WoodBoomerangEntity entityIn, float entityYaw, float partialTicks, MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn) { IVertexBuilder ivertexbuilder = net.minecraft.client.renderer.ItemRenderer.getBuffer(bufferIn, this.MODEL.getRenderType(this.getEntityTexture(entityIn)), false, false); MODEL.render(matrixStackIn, ivertexbuilder, packedLightIn, OverlayTexture.NO_OVERLAY, 1.0F, 1.0F,1.0F, 1.0F); super.render(entityIn, entityYaw, partialTicks, matrixStackIn, bufferIn, packedLightIn); } } renderer
August 22, 20214 yr Author here // Made with Blockbench 3.9.2 // Exported for Minecraft version 1.15 - 1.16 with MCP mappings // Paste this class into your mod and generate all required imports package me.oreobean.boomerang.client.models; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.vertex.IVertexBuilder; import me.oreobean.boomerang.entities.WoodBoomerangEntity; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.model.ModelRenderer; import net.minecraft.client.renderer.entity.ArrowRenderer; import net.minecraft.client.renderer.entity.BeeRenderer; public class WoodBoomerangModel<T extends WoodBoomerangEntity> extends EntityModel<WoodBoomerangEntity> { private final ModelRenderer Boomerang; private final ModelRenderer OuterArea; private final ModelRenderer Bands; private final ModelRenderer OuterArea2; private final ModelRenderer MiddleArea; public WoodBoomerangModel() { textureWidth = 32; textureHeight = 32; Boomerang = new ModelRenderer(this); Boomerang.setRotationPoint(0.0F, 24.0F, 0.0F); OuterArea = new ModelRenderer(this); OuterArea.setRotationPoint(0.0F, 0.0F, 0.0F); Boomerang.addChild(OuterArea); OuterArea.setTextureOffset(19, 21).addBox(-7.0F, -1.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); OuterArea.setTextureOffset(11, 0).addBox(-4.0F, -1.0F, -8.0F, 7.0F, 1.0F, 1.0F, 0.0F, false); OuterArea.setTextureOffset(0, 8).addBox(-8.0F, -1.0F, -4.0F, 1.0F, 1.0F, 7.0F, 0.0F, false); OuterArea.setTextureOffset(21, 18).addBox(-6.0F, -1.0F, -6.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); OuterArea.setTextureOffset(21, 16).addBox(-5.0F, -1.0F, -7.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); OuterArea.setTextureOffset(0, 8).addBox(-8.0F, -1.0F, 5.0F, 1.0F, 1.0F, 2.0F, 0.0F, false); OuterArea.setTextureOffset(0, 13).addBox(5.0F, -1.0F, -8.0F, 2.0F, 1.0F, 1.0F, 0.0F, false); Bands = new ModelRenderer(this); Bands.setRotationPoint(0.0F, 0.0F, 0.0F); Boomerang.addChild(Bands); Bands.setTextureOffset(11, 2).addBox(3.0F, -1.0F, -8.0F, 2.0F, 1.0F, 4.0F, 0.0F, false); Bands.setTextureOffset(0, 16).addBox(-8.0F, -1.0F, 3.0F, 4.0F, 1.0F, 2.0F, 0.0F, false); OuterArea2 = new ModelRenderer(this); OuterArea2.setRotationPoint(0.0F, 0.0F, 0.0F); Boomerang.addChild(OuterArea2); OuterArea2.setTextureOffset(0, 3).addBox(7.0F, -1.0F, -7.0F, 1.0F, 1.0F, 2.0F, 0.0F, false); OuterArea2.setTextureOffset(9, 11).addBox(5.0F, -1.0F, -5.0F, 2.0F, 1.0F, 1.0F, 0.0F, false); OuterArea2.setTextureOffset(12, 17).addBox(-1.0F, -1.0F, -5.0F, 4.0F, 1.0F, 1.0F, 0.0F, false); OuterArea2.setTextureOffset(15, 21).addBox(-3.0F, -1.0F, -3.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); OuterArea2.setTextureOffset(11, 21).addBox(-4.0F, -1.0F, -2.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); OuterArea2.setTextureOffset(7, 21).addBox(-2.0F, -1.0F, -4.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); OuterArea2.setTextureOffset(12, 12).addBox(-5.0F, -1.0F, -1.0F, 1.0F, 1.0F, 4.0F, 0.0F, false); OuterArea2.setTextureOffset(0, 0).addBox(-5.0F, -1.0F, 5.0F, 1.0F, 1.0F, 2.0F, 0.0F, false); OuterArea2.setTextureOffset(0, 11).addBox(-7.0F, -1.0F, 7.0F, 2.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea = new ModelRenderer(this); MiddleArea.setRotationPoint(0.0F, 0.0F, 0.0F); Boomerang.addChild(MiddleArea); MiddleArea.setTextureOffset(0, 0).addBox(-7.0F, -1.0F, -4.0F, 2.0F, 1.0F, 7.0F, 0.0F, false); MiddleArea.setTextureOffset(19, 2).addBox(-7.0F, -1.0F, 5.0F, 2.0F, 1.0F, 2.0F, 0.0F, false); MiddleArea.setTextureOffset(9, 8).addBox(-4.0F, -1.0F, -7.0F, 7.0F, 1.0F, 2.0F, 0.0F, false); MiddleArea.setTextureOffset(0, 19).addBox(5.0F, -1.0F, -7.0F, 2.0F, 1.0F, 2.0F, 0.0F, false); MiddleArea.setTextureOffset(18, 11).addBox(-5.0F, -1.0F, -5.0F, 2.0F, 1.0F, 2.0F, 0.0F, false); MiddleArea.setTextureOffset(18, 19).addBox(-3.0F, -1.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea.setTextureOffset(14, 19).addBox(-3.0F, -1.0F, -4.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea.setTextureOffset(10, 19).addBox(-5.0F, -1.0F, -3.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea.setTextureOffset(6, 19).addBox(-5.0F, -1.0F, -2.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea.setTextureOffset(18, 14).addBox(-4.0F, -1.0F, -3.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea.setTextureOffset(9, 13).addBox(-2.0F, -1.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea.setTextureOffset(11, 4).addBox(-5.0F, -1.0F, -6.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); MiddleArea.setTextureOffset(11, 2).addBox(-6.0F, -1.0F, -5.0F, 1.0F, 1.0F, 1.0F, 0.0F, false); } @Override public void setRotationAngles(WoodBoomerangEntity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch){ } @Override public void render(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha){ Boomerang.render(matrixStack, buffer, packedLight, packedOverlay); } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } @Override public void setLivingAnimations(WoodBoomerangEntity entityIn, float limbSwing, float limbSwingAmount, float partialTick) { super.setLivingAnimations(entityIn, limbSwing, limbSwingAmount, partialTick); } public ModelRenderer getBands() { return Bands; } public ModelRenderer getBoomerang() { return Boomerang; } public ModelRenderer getMiddleArea() { return MiddleArea; } public ModelRenderer getOuterArea() { return OuterArea; } public ModelRenderer getOuterArea2() { return OuterArea2; } }
August 22, 20214 yr first: https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html create a value inside your Entity which handles the rotation, update this value in the tick method of your Entity set the y rotaion of the main ModelRenderer (in your case Boomerang) to this value, do this in setRotationAngles of your Model class
August 22, 20214 yr Author I don't completely understand what you are saying can you explain in an simpler way?
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.