Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.8] Custom Armour Model Rendering


JoieNL
 Share

Recommended Posts

Recently I've gotten into making custom models for my armour sets. I have used this tutorial to guide me. Now, the armour works mostly fine. The only thing that goes wrong is that the armour model does not change according to the entity wearing it. That is, it is always rendered small, the arms always move (even on armour stands) and the armour does not follow the player sneaking, holding an item, guarding with a sword, etc. I do realise that some of these things can be circumvented by changing certain fields in ModelBiped and ModelBase (e.g. isChild, isSneaking), but these fields do not cover every movement. How would I go about making the armour render correctly according to the attributes of the entity wearing it? Thanks in advance for any help!

 

Here are the classes involved for reference:

 

ModelElementalArmourIce.java:

Spoiler

public class ModelElementalArmourIce extends ModelBiped {

    public ModelElementalArmourIce(int slot, float scale) {
        super(scale, 0, 64, 64);

        ModelRenderer icyEyes = new ModelRenderer(this, 0, 32);
        icyEyes.addBox(-11F, -3F, 0F, 22, 8, 0);
        icyEyes.setRotationPoint(0F, -8F, -5.1F);
        icyEyes.setTextureSize(64, 64);
        icyEyes.mirror = true;
        setRotation(icyEyes, 0F, 0F);
        bipedHeadwear.addChild(icyEyes);

        ModelRenderer spike1 = new ModelRenderer(this, 48, 32);
        spike1.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
        spike1.setRotationPoint(1.5F, 2.5F, 2F);
        spike1.setTextureSize(64, 64);
        setRotation(spike1, 0.2617994F, 0.0872665F);
        bipedBody.addChild(spike1);

        ModelRenderer spike2 = new ModelRenderer(this, 48, 32);
        spike2.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
        spike2.setRotationPoint(-1.5F, 2.5F, 2F);
        spike2.setTextureSize(64, 64);
        spike2.mirror = true;
        setRotation(spike2, 0.2617994F, -0.0872665F);
        bipedBody.addChild(spike2);

        ModelRenderer spike3 = new ModelRenderer(this, 48, 32);
        spike3.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
        spike3.setRotationPoint(2F, 6F, 2F);
        spike3.setTextureSize(64, 64);
        setRotation(spike3, 0F, 0.1745329F);
        bipedBody.addChild(spike3);

        ModelRenderer spike4 = new ModelRenderer(this, 48, 32);
        spike4.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
        spike4.setRotationPoint(-2F, 6F, 2F);
        spike4.setTextureSize(64, 64);
        spike4.mirror = true;
        setRotation(spike4, 0F, -0.1745329F);
        bipedBody.addChild(spike4);

        ModelRenderer spike5 = new ModelRenderer(this, 48, 32);
        spike5.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
        spike5.setRotationPoint(1.5F, 9.5F, 2F);
        spike5.setTextureSize(64, 64);
        setRotation(spike5, -0.2617994F, 0.0872665F);
        bipedBody.addChild(spike5);

        ModelRenderer spike6 = new ModelRenderer(this, 48, 32);
        spike6.addBox(-0.5F, -0.5F, 0F, 1, 1, 4);
        spike6.setRotationPoint(-1.5F, 9.5F, 2F);
        spike6.setTextureSize(64, 64);
        spike6.mirror = true;
        setRotation(spike6, -0.2617994F, -0.0872665F);
        bipedBody.addChild(spike6);

        ModelRenderer clawRightFront = new ModelRenderer(this, 44, 32);
        clawRightFront.addBox(0F, 0F, -0.5F, 1, 5, 1);
        clawRightFront.setRotationPoint(-3F, 10F, -0.7F);
        clawRightFront.setTextureSize(64, 64);
        clawRightFront.mirror = true;
        setRotation(clawRightFront, 0F, 0F);
        bipedRightArm.addChild(clawRightFront);

        ModelRenderer clawRightBack = new ModelRenderer(this, 44, 32);
        clawRightBack.addBox(0F, 0F, -0.5F, 1, 5, 1);
        clawRightBack.setRotationPoint(-3F, 10F, 0.67F);
        clawRightBack.setTextureSize(64, 64);
        clawRightBack.mirror = true;
        setRotation(clawRightBack, 0F, 0F);
        bipedRightArm.addChild(clawRightBack);

        ModelRenderer clawLeftFront = new ModelRenderer(this, 44, 32);
        clawLeftFront.addBox(-1F, 0F, -0.5F, 1, 5, 1);
        clawLeftFront.setRotationPoint(3F, 10F, -0.7F);
        clawLeftFront.setTextureSize(64, 64);
        setRotation(clawLeftFront, 0F, 0F);
        bipedLeftArm.addChild(clawLeftFront);

        ModelRenderer clawLeftBack = new ModelRenderer(this, 44, 32);
        clawLeftBack.addBox(-1F, 0F, -0.5F, 1, 5, 1);
        clawLeftBack.setRotationPoint(3F, 10F, 0.7F);
        clawLeftBack.setTextureSize(64, 64);
        setRotation(clawLeftBack, 0F, 0F);
        bipedLeftArm.addChild(clawLeftBack);

        switch (slot) {
            case 0:
                bipedHeadwear.showModel = true;
                bipedHead.showModel = true;
                bipedBody.showModel = false;
                bipedLeftArm.showModel = false;
                bipedRightArm.showModel = false;
                bipedLeftLeg.showModel = false;
                bipedRightLeg.showModel = false;
                break;
            case 1:
                bipedHeadwear.showModel = false;
                bipedHead.showModel = false;
                bipedBody.showModel = true;
                bipedLeftArm.showModel = true;
                bipedRightArm.showModel = true;
                bipedLeftLeg.showModel = false;
                bipedRightLeg.showModel = false;
                break;
            case 2:
                bipedHeadwear.showModel = false;
                bipedHead.showModel = false;
                bipedBody.showModel = true;
                bipedLeftArm.showModel = false;
                bipedRightArm.showModel = false;
                bipedLeftLeg.showModel = true;
                bipedRightLeg.showModel = true;

                spike1.showModel = false;
                spike2.showModel = false;
                spike3.showModel = false;
                spike4.showModel = false;
                spike5.showModel = false;
                spike6.showModel = false;
                break;
            case 3:
                bipedHeadwear.showModel = false;
                bipedHead.showModel = false;
                bipedBody.showModel = false;
                bipedLeftArm.showModel = false;
                bipedRightArm.showModel = false;
                bipedLeftLeg.showModel = true;
                bipedRightLeg.showModel = true;
                break;
        }
    }

    public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) {
        super.render(entity, f, f1, f2, f3, f4, f5);
        super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);
    }

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

 

 

ElementalArmourItem.java:

Spoiler

[unimportant contructors and the like]

@Override
@SideOnly(Side.CLIENT)
public ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, int armorSlot) {
  GL11.glPushMatrix();
  GL11.glEnable(GL11.GL_BLEND);
  GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
  GL11.glPopMatrix();
  ModelElementalArmourIce model = ClientProxy.getElementalArmourModel(4 - armorSlot);
  return model;
}

 

 

ClientProxy.java:

Spoiler

public class ClientProxy extends CommonProxy {

    private static ModelElementalArmourIce[] elementalArmour;

    [preInit]

    @Override
    public void init(FMLInitializationEvent e) {
        super.init(e);
        elementalArmour = new ModelElementalArmourIce[4];
        elementalArmour[0] = new ModelElementalArmourIce(0, 0.5F);
        elementalArmour[1] = new ModelElementalArmourIce(1, 1.0F);
        elementalArmour[2] = new ModelElementalArmourIce(2, 0.5F);
        elementalArmour[3] = new ModelElementalArmourIce(3, 0.5F);
        [other stuff]
    }

    [postInit]

    public static ModelElementalArmourIce getElementalArmourModel(int slot) {
        return elementalArmour[slot];
    }
}

 

 

Edited by JoieNL
Link to comment
Share on other sites

A few days have passed now and I have made little progress. I have found a way to easily apply most important attributes that the model can have:

@Override
    @SideOnly(Side.CLIENT)
    public ModelBiped getArmorModel(EntityLivingBase entity, ItemStack stack, int armorSlot) {
        [...]
        ModelElementalArmourIce model = ClientProxy.getElementalArmourModel(4 - armorSlot);
        ModelBase defaultModel = RendererLivingEntity.class.cast(Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(entity)).getMainModel();
        model.setModelAttributes(defaultModel);
        return model;
    }

This way of doing things does not look particularly beautiful and I would not be surprised if there was some better way of retrieving an entity's default model.

 

Of course, my problem still stands. I have experimented some more with the armour, and have been able to pinpoint several issues that all relate to the entity wearing the armour.

- On armour stands, the helmet's front always faces south and the arms move (idle animation).

- For entities that have their arms sticking forward (e.g. zombies, skeletons), the armour's arms simply hang downwards.

- Zombie villagers also have their heads sticking out the top of the helmet.

 

I will persist in trying to find a solution. I hope someone may be able to help me out.

Link to comment
Share on other sites

Why are you casting that way? 

(ModelBase)foo is sufficient. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Right, that was just a thing I left there for no reason. The casting is to RendererLivingEntity by the way, not ModelBase. Here's the preferred thing:

ModelBase defaultModel = ((RendererLivingEntity) Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(entity)).getMainModel();

The weird cast was there because I was getting confused with both RendererLiving and Render being generic classes.

 

Anyway, this is kind of besides the point of the thread, and I still haven't made any progress on the topic.

Edited by JoieNL
Link to comment
Share on other sites

36 minutes ago, JoieNL said:

Right, that was just a thing I left there for no reason. The casting is to RendererLivingEntity by the way, not ModelBase.

you are correct, I'm on a tablet right now, so things are tricky. 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

I thought maybe another mod's code might help me out. I know Twilight Forest has some custom armour models and luckily for me the source code is on GitHub. I will look into things a bit more and report my findings.

Edited by JoieNL
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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • I also getting issues with installing Forge serve  JVM info: Eclipse Adoptium - 17.0.1 - 17.0.1+12 java.net.preferIPv4Stack=true Found java version 17.0.1 <html><a href='https://www.creeperhost.net/'>Data kindly mirrored by CreeperHost</a></html> Considering minecraft server jar javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target     at java.base/sun.security.ssl.Alert.createSSLException(Alert.java:131)     at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:370)     at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:313)     at java.base/sun.security.ssl.TransportContext.fatal(TransportContext.java:308)     at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1357)     at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.onConsumeCertificate(CertificateMessage.java:1232)     at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.consume(CertificateMessage.java:1175)     at java.base/sun.security.ssl.SSLHandshake.consume(SSLHandshake.java:396)     at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:480)     at java.base/sun.security.ssl.HandshakeContext.dispatch(HandshakeContext.java:458)     at java.base/sun.security.ssl.TransportContext.dispatch(TransportContext.java:200)     at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:172)     at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1500)     at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1415)     at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450)     at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:421)     at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:580)     at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1665)     at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1589)     at java.base/java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:529)     at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:308)     at net.minecraftforge.installer.DownloadUtils.getConnection(DownloadUtils.java:243)     at net.minecraftforge.installer.DownloadUtils.downloadManifest(DownloadUtils.java:307)     at net.minecraftforge.installer.json.Util.getVanillaVersion(Util.java:73)     at net.minecraftforge.installer.actions.ServerInstall.run(ServerInstall.java:86)     at net.minecraftforge.installer.InstallerPanel.run(InstallerPanel.java:423)     at net.minecraftforge.installer.SimpleInstaller.launchGui(SimpleInstaller.java:175)     at net.minecraftforge.installer.SimpleInstaller.main(SimpleInstaller.java:147) Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target     at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:439)     at java.base/sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:306)     at java.base/sun.security.validator.Validator.validate(Validator.java:264)     at java.base/sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)     at java.base/sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)     at java.base/sun.security.ssl.CertificateMessage$T13CertificateConsumer.checkServerCerts(CertificateMessage.java:1341)     ... 24 more Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target     at java.base/sun.security.provider.certpath.SunCertPathBuilder.build(SunCertPathBuilder.java:141)     at java.base/sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:126)     at java.base/java.security.cert.CertPathBuilder.build(CertPathBuilder.java:297)     at java.base/sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:434)     ... 29 more Failed to download version manifest, can not find server jar URL.    
    • crash report: https://pastebin.com/DAAFEVzq  this is the crash report of my friend, we both start up a forge server 36.2.22, to me works just fine, but to him instantly crashes at start up java i used: adoptium jdk 8 java he used: latest java 8 64 bit and also tried with adoptium jdk 8
    • I've been struggling with setting up a 1.16.5 Minecraft server, I've done this before and never had issues..  Every time I try to open the ForgeServer.jar file to launch the server with, nothing happens. And when I try to run it through the linked bat file, I get the following: https://imgur.com/X1K3jd1 I have java 8 version 321 installed and am using the latest Forge 1.16.5-36.2.23 on both client and server. I'm not sure what I'm doing wrong here. I previously had the wrong java installed, which is now fixed. I've tried to remake the server several times, re-installed Minecraft and java and used Jarfix.  I'll also include a picture of the server files to know the file names etc, don't know if that may help or not. Written in the Run.bat: java -Xmx4G -Xms4G -jar ForgeServer.jar nogui Pause https://imgur.com/Sq9k0Ws
    • create a new server an copy the world and mods folder into the new server, if you have changed the configs you also need to copy it. Also note if you have banned player or you use a whitelist/ you opt players you have to copy these files. This is the way I use, theoretically it's also possible to only replace the libraries folder and the run script files. But I haven't test that.  nevermind D7 way is 10 times better😅 I would also recommend you to create a backup of the server before updating 
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.