Jump to content

[1.7.10] [SOLVED] OBJ Armor Rendering


Izzy Axel

Recommended Posts

I've been looking into this for a while now, but the other threads asking about this either got no answers, got answers that didn't explain much and seemed to be outdated (the getArmorModel function in ItemArmor doesn't exist in 1.7.10?), or pointed to mod sources that just confused me more than when I started (iChun's hat mod, Botania, etc).  So, what's the best way to render an IModelCustom on the player?  I already have IEEP and a player tick handler set up to tell when the armor is being worn, and the armor is finished, so all that's left is rendering.

 

Armor Item

 

I tried this and many different things in it, but it did absolutely nothing every time:

IItemRender

with this in main mod class:

MinecraftForgeClient.registerItemRenderer(AAItems.crownOfIris, new IrisRender());

Link to comment
Share on other sites

getArmorModel

is a method of

Item

in 1.7.10 (though for some reason it's only called if the

Item

is an instance of

ItemArmor

). It expects a

ModelBiped

, though; so you'd either have to convert your models to Java models or create an adapter class that extends

ModelBiped

but renders an OBJ model.

 

I don't know much about the rendering system, so I can't help much more than that.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

That would be why I didn't see getArmorModel.  An adapter doesn't seem hard, but this isn't working and gives no errors, so I'm not sure what to do now:

 

 

ItemCrownOfIris:

public class ItemCrownOfIris extends ItemArmor implements ISpecialArmor
{
   public ItemCrownOfIris(ArmorMaterial armormat, int renderIndex, int slot)
   {
      super(armormat, renderIndex, slot);
      this.setUnlocalizedName("crownOfIris");
      this.setTextureName(AAReference.MODID + ":" + getUnlocalizedName().substring(5));
      this.setMaxStackSize(1);
      this.setCreativeTab(AACreativeTab.aaTab);
      AAUtils.AADespawn.registerItemToNeverDespawn(this);
      MinecraftForge.EVENT_BUS.register(this);
   }


   @SideOnly(Side.CLIENT)
   @Override
   public ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, int armorSlot)
   {
      return new IrisRender();
   }


   @Override
   public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
   {
      return AAReference.MODID + ":textures/models/armor/crownOfIrisInvis.png";
   }


   @Override
   public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {}


   @Override
   public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
   {
      return new ArmorProperties(1000, 1000, 1000);
   }


   @Override
   public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot)
   {
      return 0;
   }


   @SubscribeEvent(receiveCanceled = true)
   public void onDamage(LivingHurtEvent event)
   {
      if(event.entityLiving instanceof EntityPlayer)
      {
         EntityPlayer player = (EntityPlayer)event.entityLiving;
         AAExtendedPlayer props = (AAExtendedPlayer)player.getExtendedProperties(AAExtendedPlayer.EEPName);
         if(props.hasCrown())
         {
            for(int i = 0; i < (int)event.ammount * 4; i++)
            {
               if(!event.entity.worldObj.isRemote)
               {
                  ArcaneArtificing.snw.sendToAllAround(new MessageDoParticles(AAReference.CrownRainbowFX, player.posX + ((itemRand.nextInt(3) - 1) * itemRand.nextFloat()), player.posY + 1.5 + ((itemRand.nextInt(3) - 1) * itemRand.nextFloat()), player.posZ + ((itemRand.nextInt(3) - 1) * itemRand.nextFloat()), 0, 0, 0, 40f, 20), new NetworkRegistry.TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 256));
               }
            }
            event.ammount = 0;
         }
      }
   }
}

 

 

IrisRender:

public class IrisRender extends ModelBiped
{
   IModelCustom CrownOfIris;
   ResourceLocation CrownTexture;


   public IrisRender()
   {
      super();
      this.CrownOfIris = AdvancedModelLoader.loadModel(new ResourceLocation(AAReference.MODID, "models/CrownOfIris.obj"));
      this.CrownTexture = new ResourceLocation(AAReference.MODID, "textures/models/armor/crownOfIris.png");
   }


   @Override
   public void render(Entity entity, float time, float armsLegs, float headAngleY, float headAngleX, float p_78088_6_, float p_78088_7_)
   {
      if(entity instanceof EntityPlayer)
      {
         GL11.glPushMatrix();
         GL11.glTranslatef(0.0F, 0.5F, 0.0F);
         this.CrownOfIris.renderAll();
         GL11.glPopMatrix();
      }
   }
}

 

 

Edit: Imma derp Imma derp Imma derp derp derp!  Never bound a texture to it.  I'm not sure where else to get access to the TextureManager, so this might not work on server/may be bad practice, but this works on SSP:

 

 

public class IrisRender extends ModelBiped
{
   IModelCustom CrownOfIris = AdvancedModelLoader.loadModel(new ResourceLocation(AAReference.MODID, "models/CrownOfIris.obj"));
   ResourceLocation CrownTexture = new ResourceLocation(AAReference.MODID, "textures/models/armor/crownOfIris.png");


   @Override
   public void render(Entity entity, float time, float armsLegs, float headAngleY, float headAngleX, float p_78088_6_, float p_78088_7_)
   {
      if(entity instanceof EntityPlayer)
      {
         GL11.glPushMatrix();
         Minecraft.getMinecraft().getTextureManager().bindTexture(this.CrownTexture);
         GL11.glRotatef(time, 0.0f, 1.0f, 0.0f);
         GL11.glTranslatef(0.0F, 16.0F * p_78088_7_, 0.0F);
         this.CrownOfIris.renderAll();
         GL11.glPopMatrix();
      }
   }
}

 

Edit 2: It isn't working on a server with other mods, it is working on a server with only my mod, and it's overwriting all other mod's armor rendering, (though not vanilla) so we got a problem :P

Link to comment
Share on other sites

  • 1 year later...

I know that this is very old. But I was wondering if this has been done or figured out for 1.10.2. Is this different for 1.10.2?

 

Eventually I'll rewrite my OBJ reader/renderer for 1.10+, but from what I heard, Forge added OBJ support to the vanilla model system, can that not be used for armor?

 

PS your inbox is full

Link to comment
Share on other sites

I have looked into this a lot and talked to people on the irc channel, the obj was added for blocks and items but not armor. I still am working on figuring out how to get a custom renderer for the armors. I am testing out the one that you have posted here for 1.7.10 to see how that one works. When I load in a model for a helmet the the model is huge and in the wrong place. Do I need to include a json file in 1.7.10 for the examples above?

 

I really want to figure this out so that I can move forward with my mod idea.

Link to comment
Share on other sites

I have looked into this a lot and talked to people on the irc channel, the obj was added for blocks and items but not armor. I still am working on figuring out how to get a custom renderer for the armors. I am testing out the one that you have posted here for 1.7.10 to see how that one works. When I load in a model for a helmet the the model is huge and in the wrong place. Do I need to include a json file in 1.7.10 for the examples above?

 

I really want to figure this out so that I can move forward with my mod idea.

 

 

You need to use OpenGL to fix its scale and position then.  1.7.10 didn't use JSON files.  This currently uses my own loader/renderer but it's a drop-in replacement for the AdvancedModelLoader: IrisRender

 

 

Edit: actually you can also fix its scale and position by scaling/positioning it in your 3D modeling program too.  In Maya (the program I use) 1 cubic unit = 1 block in MC, which makes it very easy to position/scale the model file, so not much OpenGL is required.

Link to comment
Share on other sites

I am trying to use that Jade API, I try to load it into 1.7.10 and it wont work, the Read me says that it is a 1.10.2 API but when I load it there it says that the API needs 1.7.10  :(

I got this to work but I had to tweak the API a little to do so

 

There's no point in trying to use Jade if you're trying to make armor OBJ models for 1.7.10, it does the same thing as the Forge OBJ loader, the only difference is that it's faster, never discards faces, and respects normal angles.  The version on my github is a very early start to the 1.10.2 version iirc, I don't think I ever pushed a 1.7.10 version.  Whatever happened, I'm pretty sure it's not in a fully functional state for either version.  I haven't been working on anything MC or even Java related in a while, I'm off in C/C++ land at least until I finish the projects I'm working on atm.

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

    • There's a scheme I got into where they promised to trade Bitcoin for me and take a cut as a commission. Seemed like a good idea at the time. But then, things went south real fast. They ended up transferring   $190,000 worth of my Bitcoin. I was devastated and felt completely helpless. That's when I stumbled upon the Wizard Web Recovery Tool. It was like a beacon of hope amid chaos. With this tool, I could finally start digging into what went wrong and hopefully get my Bitcoin back. Using Wizard Web was surprisingly easy. I just had to plug in some details about my Bitcoin account and let it do its thing. It started scanning the internet, looking for any clues about what happened to my Bitcoin. It felt like having a detective on my side, searching for answers. And guess what? Wizard Web found some leads. It uncovered evidence of the scheme's shady dealings and helped me track down the people responsible for losing my Bitcoin. Armed with this information, I took the case to court. After a long and hard-fought legal battle, the court ruled in my favor. The perpetrators were held accountable for their actions and faced criminal charges for their involvement in the scheme. It was a victory not just for me, but for anyone who's been taken advantage of by these kinds of scams. Thanks to Wizard Web Recovery, I was able to get justice and reclaim what was rightfully mine. It showed me that even in the face of adversity, there's always a way to fight back. And with the right tools and determination, anything is possible.   The following is the contact information for Wizard Web Recovery.   Email: wizard web recovery((@))programmer . net
    • Hello, good morning. I know some programming and I'm interested in mod creation. That's why I've decided to follow a tutorial guide on YouTube by TurtyWurty. https://www.youtube.com/watch?v=DhoX9cmAZqA&t=160s&ab_channel=TurtyWurty I've followed the tutorial perfectly. The problem is that when checking the food, the texture doesn't load for me. However, everything seems fine no matter how much I check. I'm sure it's something trivial, the problem is that I can't find it. Could you help me solve it, please? I leave a zip of my file so you can edit it freely. forge-1.20-Civicraft.rar
    • If you have nvidia graphics, it's important that you make sure Minecraft (and anything Minecraft-related) is set to prefer high performance graphics first. If you only update your AMD drivers it might fix the issue but cause severe performance loss vs Vanilla as it'll be running on the integrated graphics instead of dedicated nvidia graphics
    • Update your drivers: https://www.amd.com/en/support/downloads/drivers.html/processors/ryzen/ryzen-5000-series/amd-ryzen-5-5600g.html
  • Topics

×
×
  • Create New...

Important Information

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