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



×
×
  • Create New...

Important Information

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