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

    • I'm using Modrinth as a launcher for a forge modpack on 1.20.1, and can't diagnose the issue on the crash log myself. Have tried repairing the Minecraft instillation as well as removing a few mods that have been problematic for me in the past to no avail. Crash log is below, if any further information is necessary let me know. Thank you! https://paste.ee/p/k6xnS
    • Hey folks. I am working on a custom "Mecha" entity (extended from LivingEntity) that the player builds up from blocks that should get modular stats depending on the used blocks. e.g. depending on what will be used for the legs, the entity will have a different jump strength. However, something unexpected is happening when trying to override a few of LivingEntity's functions and using my new own "Mecha" specific fields: instead of their actual instance-specific value, the default value is used (0f for a float, null for an object...) This is especially strange as when executing with the same entity from a point in the code specific to the mecha entity, the correct value is used. Here are some code snippets to better illustrate what I mean: /* The main Mecha class, cut down for brevity */ public class Mecha extends LivingEntity { protected float jumpMultiplier; //somewhere later during the code when spawning the entity, jumpMultiplier is set to something like 1.5f //changing the access to public didn't help @Override //Overridden from LivingEntity, this function is only used in the jumpFromGround() function, used in the aiStep() function, used in the LivingEntity tick() function protected float getJumpPower() { //something is wrong with this function //for some reason I can't correctly access the fields and methods from the instanciated entity when I am in one of those overridden protected functions. this is very annoying LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 0f return this.jumpMultiplier * super.getJumpPower(); } //The code above does not operate properly. Written as is, the entity will not jump, and adding debug logs shows that when executing the code, the value of this.jumpMultiplier is 0f //in contrast, it will be the correct value when done here: @Override public void tick() { super.tick(); //inherited LivingEntity logic //Custom logic LogUtils.getLogger().info(String.valueOf(this.jumpMultiplier))) //will print 1.5f } } My actual code is slightly different, as the jumpMuliplier is stored in another object (so I am calling "this.legModule.getJumpPower()" instead of the float), but even using a simple float exactly like in the code above didn't help. When running my usual code, the object I try to use is found to be null instead, leading to a crash from a nullPointerException. Here is the stacktrace of said crash: The full code can be viewed here. I have found a workaround in the case of jump strength, but have already found the same problem for another parameter I want to do, and I do not understand why the code is behaving as such, and I would very much like to be able to override those methods as intended - they seemed to work just fine like that for vanilla mobs... Any clues as to what may be happening here?
    • Please delete post. Had not noticed the newest edition for 1.20.6 which resolves the issue.
    • https://paste.ee/p/GTgAV Here's my debug log, I'm on 1.18.2 with forge 40.2.4 and I just want to get it to work!! I cant find any mod names in the error part and I would like some help from the pros!! I have 203 mods at the moment.
  • Topics

×
×
  • Create New...

Important Information

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