Jump to content

[1.8.9] [SOLVED] Help with Mob model rotation rendering


Nemesis

Recommended Posts

So I am trying to make a deer mob. The AI works, the deer is being initialized correctly and the model looks almost right. I only have a problem with rendering cubes with custom rotation. The problem is some what weird because rotateAngel y and z does work, but I can't get rotate Angel x to work. Boxes like head (which is slightly rotated with x value) appear in-game with no rotation.

Can someone please tell me what I am doing wrong here ;D

 

the code:

public class ModelHirvi extends ModelBase{

public ModelRenderer body = new ModelRenderer(this, 0, 0);
public ModelRenderer kaula;
public ModelRenderer hanta;
public ModelRenderer head;

public ModelRenderer horno;
public ModelRenderer hornv;

    public ModelRenderer lankieo;
    public ModelRenderer lankiev;
    public ModelRenderer lankito;
    public ModelRenderer lankitv;

public ModelRenderer leg3eo;
public ModelRenderer leg4ev;
public ModelRenderer leg1to;
public ModelRenderer leg2tv;

public ModelHirvi()
{
	textureWidth = 64;
	textureHeight = 64;


	this.horno = new ModelRenderer(this, 14, 0);
	this.horno.addBox(-2F, 1F, 1.5F, 1, 3, 4);
	this.horno.setRotationPoint(0F, -7F, -9F);
	this.setRotation(horno, 0.1308997F, -1.151917F, -0.4014257F);


	this.hornv = new ModelRenderer(this, 14, 0);
	this.hornv.addBox(1F, 1F, 2F, 1, 3, 4);
	this.hornv.setRotationPoint(0F, -7F, -9F);
	this.setRotation(hornv, 0.1308997F, 1.151917F, 0.4014257F);

                //rotation not rendering correctly:
	this.head = new ModelRenderer(this, 40, 0);
	this.head.addBox(-3F, 0F, -6F, 6, 9, 6);
	this.head.setRotationPoint(0F, -1F, -6F);
	this.head.setTextureOffset(0, 41).addBox(-2.5F, 9F, -5.5F, 5, 4, 5);
                this.setRotation(head, 0.2235988F, 0F, 0F);



	this.leg1to = new ModelRenderer(this, 0, 0);
	this.leg1to.addBox(-3F, 0F, -2F, 3, 12, 3);
        this.leg1to.setRotationPoint(-3F, 12F, 11F);
    
		this.leg2tv = new ModelRenderer(this, 0, 0);
	this.leg2tv.addBox(0F, 0F, 0F, 3, 12, 3);
        this.leg2tv.setRotationPoint(3F, 12F, 9F);
    
        this.leg3eo = new ModelRenderer(this, 0, 0);
	this.leg3eo.addBox(-3F, 0F, -3F, 3, 12, 3);
        this.leg3eo.setRotationPoint(-3F, 12F, -5F);
    
	this.leg4ev = new ModelRenderer(this, 0, 0);
	this.leg4ev.addBox(-1F, 0F, -3F, 3, 12, 3);
        this.leg4ev.setRotationPoint(4F, 12F, -5F);
    
	this.body = new ModelRenderer(this, 22, 32);
	this.body.addBox(-5F, -10F, -11F, 10, 21, 11);
	this.body.setRotationPoint(0F, 3F, 2F);

	this.lankieo = new ModelRenderer(this, 11, 16);
        this.lankieo.addBox(-6F, 5F, -10.5F, 1, 6, 4);
        this.lankieo.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankieo, 0F, 0F, 0F);
    
        this.lankiev = new ModelRenderer(this, 11, 16);
        this.lankiev.addBox(5F, 5F, -10.5F, 1, 6, 4);
        this.lankiev.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankiev, 0F, 0F, 0F);

        this.lankito = new ModelRenderer(this, 0, 16);
        this.lankito.addBox(-6F, 1F, 6.5F, 1, 10, 4);
        this.lankito.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankito, 0F, 0F, 0F);
     
        this.lankitv = new ModelRenderer(this, 0, 16);
        this.lankitv.addBox(5F, 1F, 6.5F, 1, 10, 4);
        this.lankitv.setRotationPoint(0F, 3F, 2F);
        this.setRotation(lankitv, 0F, 0F, 0F);

                //rotation not rendering correctly:
        this.kaula = new ModelRenderer(this, 0, 51);
	this.kaula.addBox(-3F, -8F, 0F, 6, 8, 5);
        this.kaula.setRotationPoint(0F, 7F, -8F);
         this.setRotation(kaula, 0.4461433F, 0F, 0F);

                //rotation not rendering correctly:
	this.hanta = new ModelRenderer(this, 26, 0);
	this.hanta.addBox(-1.5F, -3F, 0F, 3, 5, 3);
        this.hanta.setRotationPoint(0F, 4F, 13F);
        this.setRotation(hanta, 2.240011F, 0F, 0F);

    
}


	public void render(Entity entity, float time, float limbSwingDistance, float p_78087_3_, float headYRot, float headXRot, float Ytrans)
	{
		this.setRotationAngles(time, limbSwingDistance, p_78087_3_, headYRot, headXRot, Ytrans, entity);

		if(this.isChild)
		{
			float div = 2.0F;
			GlStateManager.pushMatrix();
			GlStateManager.scale(1.0F/div, 1.0F/div, 1.0F/div);
			GlStateManager.translate(0.0F, 24.0F * Ytrans, 0.0F);

			this.head.render(Ytrans);
			this.kaula.render(Ytrans);
			this.hanta.render(Ytrans);
			this.horno.render(Ytrans);
			this.hornv.render(Ytrans);
			this.body.render(Ytrans);
			this.leg1to.render(Ytrans);
			this.leg2tv.render(Ytrans);
			this.leg3eo.render(Ytrans);
			this.leg4ev.render(Ytrans);
			this.lankieo.render(Ytrans);
			this.lankiev.render(Ytrans);
			this.lankito.render(Ytrans);
			this.lankitv.render(Ytrans);
			GlStateManager.popMatrix();
		}
		else
		{
			this.head.render(Ytrans);
			this.kaula.render(Ytrans);
			this.hanta.render(Ytrans);
			this.horno.render(Ytrans);
			this.hornv.render(Ytrans);
			this.body.render(Ytrans);
			this.leg1to.render(Ytrans);
			this.leg2tv.render(Ytrans);
			this.leg3eo.render(Ytrans);
			this.leg4ev.render(Ytrans);
			this.lankieo.render(Ytrans);
			this.lankiev.render(Ytrans);
			this.lankito.render(Ytrans);
			this.lankitv.render(Ytrans);
		}
	}


	 private void setRotation(ModelRenderer model, float x, float y, float z)
	    {
	        model.rotateAngleX = x;
	        model.rotateAngleY = y;
	        model.rotateAngleZ = z;
	    }

	public void setRotationAngles(float time, float limbSwingDistance, float p_78087_3_, float headYRot, float headXRot, float p_78087_6_, Entity entity) 
	{
		this.head.rotateAngleX = headXRot / (300F / (float)Math.PI);
		this.head.rotateAngleX = headYRot / (300F / (float)Math.PI);

		this.horno.rotateAngleX = headXRot / (180F / (float)Math.PI);
		this.horno.rotateAngleX = headYRot / (180F / (float)Math.PI);

		this.hornv.rotateAngleX = headXRot / (180F / (float)Math.PI);
		this.hornv.rotateAngleX = headYRot / (180F / (float)Math.PI);

		this.body.rotateAngleX = ((float)Math.PI / 2F);
		this.kaula.rotateAngleX = ((float)Math.PI / 2F);
		this.hanta.rotateAngleX = ((float)Math.PI / 2F);
		this.lankieo.rotateAngleX = ((float)Math.PI / 2F);
		this.lankiev.rotateAngleX = ((float)Math.PI / 2F);
		this.lankito.rotateAngleX = ((float)Math.PI / 2F);
		this.lankitv.rotateAngleX = ((float)Math.PI / 2F);

		this.leg1to.rotateAngleX = MathHelper.cos(time * 0.6662F) * 1.4F * limbSwingDistance;
		this.leg2tv.rotateAngleX = MathHelper.cos(time * 0.6662F + (float)Math.PI) * 1.4F * limbSwingDistance;
		this.leg3eo.rotateAngleX = MathHelper.cos(time * 0.6662F + (float)Math.PI) * 1.4F * limbSwingDistance;
		this.leg4ev.rotateAngleX = MathHelper.cos(time * 0.6662F) * 1.4F * limbSwingDistance;

	}



}


 

You want to see my code so far? Here it is: System.out.println("Hello, World");

Link to comment
Share on other sites

Why can't you just render everything without rotation then rotate the parts in set RotationAngles?

 

Thanks mate. How dumb from me to first tell the x value and then override it in set RotationAngels. I just deleted the this.setrotation and add all the rotation values to set RotationAngels

You want to see my code so far? Here it is: System.out.println("Hello, World");

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi guys! I am having some issues with the server crashing over and over and I was hoping to get some guidance.  Thanks in advance! Crash 1: java.lang.Error: ServerHangWatchdog detected that a single server tick took 60.00 seconds (should be max 0.05)     at net.minecraft.server.dedicated.ServerWatchdog.run(ServerWatchdog.java:43) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:classloading}     at java.lang.Thread.run(Thread.java:840) ~[?:?] { Crash 2: java.lang.IllegalStateException: Capability missing for eeb7f026-34b4-42f5-9164-e7736461df83     at me.lucko.luckperms.forge.capabilities.UserCapabilityImpl.lambda$get$0(UserCapabilityImpl.java:66) ~[?:?] {re:classloading,re:classloading,re:classloading}     at net.minecraftforge.common.util.LazyOptional.orElseThrow(LazyOptional.java:261) ~[forge-1.20.1-47.3.10-universal.jar%23222!/:?] {re:mixin,re:classloading}     at me.lucko.luckperms.forge.capabilities.UserCapabilityImpl.get(UserCapabilityImpl.java:66) ~[?:?] {re:classloading,re:classloading,re:classloading}     at me.lucko.luckperms.forge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:143) ~[?:?] {}     at me.lucko.luckperms.forge.util.BrigadierInjector$InjectedPermissionRequirement.test(BrigadierInjector.java:129) ~[?:?] {}     at com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:65) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parseNodes(CommandDispatcher.java:359) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:349) ~[brigadier-1.1.8.jar%2376!/:?] {}     at com.mojang.brigadier.CommandDispatcher.parse(CommandDispatcher.java:317) ~[brigadier-1.1.8.jar%2376!/:?] {}     at net.minecraft.commands.Commands.m_230957_(Commands.java:237) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:classloading}     at net.mcreator.boh.procedures.TeleportbenProcedure.lambda$execute$2(TeleportbenProcedure.java:65) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at net.mcreator.boh.BohMod.lambda$tick$2(BohMod.java:96) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at java.util.ArrayList.forEach(ArrayList.java:1511) ~[?:?] {re:mixin}     at net.mcreator.boh.BohMod.tick(BohMod.java:96) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading}     at net.mcreator.boh.__BohMod_tick_ServerTickEvent.invoke(.dynamic) ~[boh-0.0.6.1-forge-1.20.1_2.jar%23165!/:?] {re:classloading,pl:eventbus:B}     at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:315) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:296) ~[eventbus-6.0.5.jar%2352!/:?] {}     at net.minecraftforge.event.ForgeEventFactory.onPostServerTick(ForgeEventFactory.java:950) ~[forge-1.20.1-47.3.10-universal.jar%23222!/:?] {re:classloading}     at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:835) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:661) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:251) ~[server-1.20.1-20230612.114412-srg.jar%23217!/:?] {re:mixin,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,re:classloading,pl:accesstransformer:B,xf:fml:xaerominimap:xaero_minecraftserver,pl:mixin:A}     at java.lang.Thread.run(Thread.java:840) ~[?:?] {}
    • Hello there! I am trying to make custom dimensions for a modpack I am making in an older minecraft version, 1.16.5. I like that version and it has a few other mods that have not been updated that I would still like to use. Anyway, I am having a terrible time with getting my dimension to work and have tried using code from other peoples projects to at least figure out what I'm supposed to be doing but it has not been as helpful as I would have liked. If anyone could help that would be greatly appreciated! Here is my github with all the code as I am using it: https://github.com/BladeColdsteel/InvigoratedDimensionsMod I have also included the last log, https://pastebin.com/zX9vsDSq, I had when I tried to load up a world, let me know if there is anything else I should send though, thank you!
    • Whether you are a fan of Hypixel Bedwars, SkyWars and PvP gamemodes like that, well you would enjoy this server! We have a very fun and unique style of PvP that a lot of our players really enjoy and we want to bring this server to more players like you! Yes you reading this post haha. Introducing, the Minezone Network, home of SUPER CRAFT BLOCKS. We've been working on this server for over 4 years now. Here is what we have to offer: SUPER CRAFT BLOCKS: This has 3 different gamemodes you can play, Classic, Duels and Frenzy. Each mode offers over 60 kits to choose from, along with a total of over 60 maps, allowing for various different playstyles on each map. There are also random powerups that spawn on the map which can include Health Pots, Bazookas, Nukes, Extra Lives and way way more! There is also double jump in this gamemode as well, which makes PvP a lot more fun & unique. You only need a minimum of 2 players to start any mode! Classic: Choose a kit, 5 lives for each player, fight it out and claim the #1 spot! Look out for lightning as they can spawn powerups to really give you an advantage in the game! Duels: Fight against another random player or one of your friends and see who is the best! Frenzy: Your kit is randomly selected for you, each life you will have a different kit. You can fight with up to 100 players in this mode and lets see who will be the best out of that 100! All the other stuff from Classic/Duels apply to this mode as well like powerups. We have 2 ranks on this server too, VIP and CAPTAIN which has a bunch of different perks for SCB and other things like Cosmetics and more.   SERVER IP: If this server has caught your interest in any way, please consider joining and you will NOT regret it! Bring some of your friends online for an even better experience and join in on the fun at: IP: minezone.club Hope to see you online!   SERVER TRAILER: https://www.youtube.com/watch?v=0phpMgu1mH0
    • The mod give new blocks  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.