Jump to content

EverythingGames

Forge Modder
  • Posts

    388
  • Joined

  • Last visited

Everything posted by EverythingGames

  1. Thanks, @coolAlias. The code I posted works until you look in your inventory (that may not be correct code, I am not at my usual workspace, I just thought of a rough idea of what my code was, sorry about that). I thought I had to use IPerspectiveAwareModel, TGG told me that about a million times...it's just that it's new and I'm not used to any of the new rendering. I'll try it later on.
  2. That's pretty useful and I appreciate your help greatly @delpi. I don't think this will work, though, because IItemRenderer is deprecated and no longer works in 1.8. I really wish Lex didn't scrap that interface. I see how you can switch the enum types based on "EQUIPPED" and "EQUIPPED_FIRST_PERSON" to fix my problem, but like I said, sadly I can't use IItemRenderer in 1.8.
  3. Thanks for the reply, @delpi. I see what you mean by the mob rendering the item for the player with first person view code. You were interested in the client side perspective getting? Here's the code (keep in mind I'm not at my usual workspace so some code may be off in terms of names): @Override @SideOnly(Side.CLIENT) public ModelResourceLocation getModel(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, int par3Integer) { boolean isFirstPerson = Minecraft.getMinecraft.gameSettings.isThirdPersonView; if(isFirstPerson) { //return first person model here } else { //return third person model here } }
  4. Thanks @delpi. I have a minor problem - I am returning models in getModel based on whether the player is in first person / third person. This works until you look in your inventory in survival mode when you are able to see your player holding the item. The player here is holding the first person item when he should be holding the third person item (I don't know why it does that when your looking at the player in the inventory third perspective). Any ideas on how to fix this? Thanks.
  5. Wow, that's just what I needed. Maybe the new system is flexible after all. So that means (based on earlier posts) I can draw a .JSON model, UV that model, bind the player's skin to it, render it, then render my other model all for just one item. Sounds great.
  6. That sounds useful for some of my later ideas. Do you know if this is possible - let's say I have an item and I want two .JSON's to render AKA two item models rendered together. Is this at all possible? I would really like to know!
  7. Thanks, coolAlias. My model is exactly the same as the vanilla model arm from the ModelPlayer class. The dimensions, texture UV, etc. The vanilla rendering of the first person hand starts in the ItemRenderer class and eventually calls a method ModelPlayer. Do you know how to actually make the model move or become attached to the player like a regular player part (such as the head or arm)? If I can do that, I can just call several GL functions to get it in front of the player and only enable first person rendering to get what I want.
  8. Hi I have rendered an arm model but the problem is that I want it to stay in front of the player much like the vanilla first person arm. I tried rotating the model based on pitch and yaw of the vanilla arm but most of it goes wrong. The yaw works fine for rotating the model up and down (in fact, it does that perfectly from what I can tell). The pitch, however, because of the model's offset / axis rotates in a weird way. Instead of rotating with the player, when the player's pitch is changed the arm tries to rotate - when it does the arm rotates in a circular motion (a simple example would be the circular motion of a drill bit, for instance). How do I correctly rotate the model ignoring the fact that the offset is at the end of the model? I hope that made sense and thanks if you are able to help out!
  9. I'm going to go ahead and close this topic and mark it as solved since all I wanted to do was render the arm. I'll need more help later on, but that's for a later post. Thanks for all the help.
  10. Hi Is it possible to bind a texture in code to a .JSON cuboid (I highly think this is not possible due to the vast limitations of the new model system...but that's why I am asking here to find out). Thanks in advance.
  11. UPDATE 2: I feel like I'm reinventing the wheel. I look at all the 1.7.10 mods that just render the arm as a part of the item while still being able to bind the players skin location. They do this in IItemRenderer when 1.8 (seems like nothing supports it and 1.9 is about to come out) doesn't have this feature anymore. Oh well, lets analyze our problem: The reason why it didn't work was because GlStateManager.push / pop matrix was called in a method before it rendered the arm - thats fixed. Here's the real problem - that code does indeed work, the only thing is that the pitch and yaw works 50%. In other words the yaw works (moving the model up and down), but the pitch doesn't. Pitch just rotates the model itself as if the arm was spinning and not actually moving with the player as the player turns. I believed this is caused by the offset / axis (the point in which the model rotates from), and I don't know what is going wrong because the arm is pretty much exactly the same as vanilla in dimmension and offset points. I am thinking we should somehow be able to attach the model to a part of the body so that the model is always in front of the player and moving according to where your looking / moving. I know some people have solved this, more help would be extremely appreciated. Thanks. public class ModelRender { private ModelLeftArm modelLeftArm = new ModelLeftArm(); public void rotateModelOne(float par1Float, float par2Float) { GlStateManager.rotate(par1Float, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(par2Float, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); } public void rotateModelTwo(EntityPlayerSP par1EntityPlayerSP, float par2Float) { float float1 = par1EntityPlayerSP.prevRenderArmPitch + (par1EntityPlayerSP.renderArmPitch - par1EntityPlayerSP.prevRenderArmPitch) * par2Float; float float2 = par1EntityPlayerSP.prevRenderArmYaw + (par1EntityPlayerSP.renderArmYaw - par1EntityPlayerSP.prevRenderArmYaw) * par2Float; GlStateManager.rotate((par1EntityPlayerSP.rotationPitch - float1) * 0.1F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate((par1EntityPlayerSP.rotationYaw - float2) * 0.1F, 0.0F, 1.0F, 0.0F); } public void setLightMap(AbstractClientPlayer par1AbstractClientPlayer) { int integer1 = Minecraft.getMinecraft().theWorld.getCombinedLight(new BlockPos(par1AbstractClientPlayer.posX, par1AbstractClientPlayer.posY + (double) par1AbstractClientPlayer.getEyeHeight(), par1AbstractClientPlayer.posZ), 0); float float1 = (float)(integer1 & 65535); float float2 = (float)(integer1 >> 16); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, float1, float2); } public void renderArmInFirstPerson(float par1Float) { EntityPlayerSP entityplayersp = Minecraft.getMinecraft().thePlayer; float f3 = entityplayersp.prevRotationPitch + (entityplayersp.rotationPitch - entityplayersp.prevRotationPitch) * par1Float; float f4 = entityplayersp.prevRotationYaw + (entityplayersp.rotationYaw - entityplayersp.prevRotationYaw) * par1Float; this.rotateModelOne(f3, f4); this.setLightMap(entityplayersp); this.rotateModelTwo(entityplayersp, par1Float); this.modelLeftArm.render(entityplayersp, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); } @SubscribeEvent public void renderHandEvent(RenderHandEvent par1RenderHandEvent) { GlStateManager.pushMatrix(); EntityPlayerSP entityplayersp = Minecraft.getMinecraft().thePlayer; Minecraft.getMinecraft().getTextureManager().bindTexture(entityplayersp.getLocationSkin()); this.renderArmInFirstPerson(par1RenderHandEvent.partialTicks); GlStateManager.popMatrix(); } }
  12. UPDATE: I've figured out the float paramters and wrote extra methods, then I rendered it. This did absolutely nothing but fix the lighting. Here's the updated code: public class ModelRender { private ModelLeftArm modelLeftArm = new ModelLeftArm(); public void rotateModelOne(float par1Float, float par2Float) { GlStateManager.pushMatrix(); GlStateManager.rotate(par1Float, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(par2Float, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); } public void rotateModelTwo(EntityPlayerSP par1EntityPlayerSP, float par2Float) { float float1 = par1EntityPlayerSP.prevRenderArmPitch + (par1EntityPlayerSP.renderArmPitch - par1EntityPlayerSP.prevRenderArmPitch) * par2Float; float float2 = par1EntityPlayerSP.prevRenderArmYaw + (par1EntityPlayerSP.renderArmYaw - par1EntityPlayerSP.prevRenderArmYaw) * par2Float; GlStateManager.rotate((par1EntityPlayerSP.rotationPitch - float1) * 0.1F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate((par1EntityPlayerSP.rotationYaw - float2) * 0.1F, 0.0F, 1.0F, 0.0F); } public void setLightMap(AbstractClientPlayer par1AbstractClientPlayer) { int integer1 = Minecraft.getMinecraft().theWorld.getCombinedLight(new BlockPos(par1AbstractClientPlayer.posX, par1AbstractClientPlayer.posY + (double) par1AbstractClientPlayer.getEyeHeight(), par1AbstractClientPlayer.posZ), 0); float float1 = (float)(integer1 & 65535); float float2 = (float)(integer1 >> 16); OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, float1, float2); } public void renderArmInFirstPerson(float par1Float) { EntityPlayerSP entityplayersp = Minecraft.getMinecraft().thePlayer; float f3 = entityplayersp.prevRotationPitch + (entityplayersp.rotationPitch - entityplayersp.prevRotationPitch) * par1Float; float f4 = entityplayersp.prevRotationYaw + (entityplayersp.rotationYaw - entityplayersp.prevRotationYaw) * par1Float; this.rotateModelOne(f3, f4); this.setLightMap(entityplayersp); this.rotateModelTwo(entityplayersp, par1Float); this.modelLeftArm.render(entityplayersp, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); } @SubscribeEvent public void renderHandEvent(RenderHandEvent par1RenderHandEvent) { EntityPlayerSP entityplayersp = Minecraft.getMinecraft().thePlayer; Minecraft.getMinecraft().getTextureManager().bindTexture(entityplayersp.getLocationSkin()); this.renderArmInFirstPerson(par1RenderHandEvent.partialTicks); } } We're almost there guys! Further help is much needed and appreciated.
  13. That goes along the lines of what is needed to be done using pitch and yaw. My model arm is the exact same as vanilla's, for further info. I have written both those obfuscated methods you have shown me, but I don't know what to plug in for those float values. Here's my code: private ModelLeftArm modelLeftArm = new ModelLeftArm(); public void rotateModelOne(float par1Float, float par2Float) { GlStateManager.pushMatrix(); GlStateManager.rotate(par1Float, 1.0F, 0.0F, 0.0F); GlStateManager.rotate(par2Float, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GlStateManager.popMatrix(); } public void rotateModelTwo(EntityPlayerSP par1EntityPlayerSP, float par2Float) { float float1 = par1EntityPlayerSP.prevRenderArmPitch + (par1EntityPlayerSP.renderArmPitch - par1EntityPlayerSP.prevRenderArmPitch) * par2Float; float float2 = par1EntityPlayerSP.prevRenderArmYaw + (par1EntityPlayerSP.renderArmYaw - par1EntityPlayerSP.prevRenderArmYaw) * par2Float; GlStateManager.rotate((par1EntityPlayerSP.rotationPitch - float1) * 0.1F, 1.0F, 0.0F, 0.0F); GlStateManager.rotate((par1EntityPlayerSP.rotationYaw - float2) * 0.1F, 0.0F, 1.0F, 0.0F); } @SubscribeEvent public void renderHandEvent(RenderHandEvent par1RenderHandEvent) { GlStateManager.pushMatrix(); EntityPlayerSP entityplayersp = Minecraft.getMinecraft().thePlayer; Minecraft.getMinecraft().getTextureManager().bindTexture(entityplayersp.getLocationSkin()); this.rotateModelOne(float); //What do I plug in here? this.rotateModelTwo(float); //What do I plug in here? this.modelLeftArm.render(entityplayersp, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GlStateManager.popMatrix(); }
  14. Hi As @diesieben07 said, check against null values. EX: if(player.getCurrentEquippedItem != null) { //do something } if(stack.getTagCompound() != null) { //do something } To set a new NBTTagCompound, do this: public void example(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(par1ItemStack.getTagCompound() == null) { par1ItemStack.setTagCompound(new NBTTagCompound()); } else { //do NBT stuff here (getting and setting) } } //An easier and slicker way of getting an NBT integer, can also be converted to return strings public int getNBTInteger(ItemStack par1ItemStack, String par2String) { return par1ItemStack.getTagCompound != null ? par1ItemStack.getTagCompound().getInteger(par2String) : null; }
  15. Here's an enormous update: 1.) I have completely created the arm model. 2.) I Have UV Mapped the model to the player's skin's arm. 3.) I Have binded and rendered the arm on the RenderHandEvent Here's what is left to do / what I need help on to complete this and mark the topic solved: 1.) This is going to be hard to describe, so bear with me. First of all, when the arm is rendered, it stays in a specific place, and does not move with the player when looking around. Here's an example - I am looking north. The arm is rendered right in front of me, I can see it. When I turn my head east, the arm does not move with the direction that I am looking, it just stays where it was first rendered and only moves with the player when I walk. How do I fix this? This is all I need to finish this render. If I was to unclear, listen to this - the default player first person arm moves with you when you look around, and doesn't just stay in one place (Kind of like I want the arm to move according to the player's head yaw and pitch. Basically the model moves according to where you are looking like the vanilla first person hand). I hope I'm making some sense, further assistance is greatly appreciated, thanks!
  16. Try this out...Its just like Techne except a lot easier, its a 3D modeling tool just for .JSON files that exports all the code for you, all you have to do is basically the same as what you do in Techne - create models the easy way by visualizing your model: *Please don't be alarmed by the website - it IS completley safe, it is just under construction to make things look nicer* http://www.mrcrayfish.com/
  17. Hi Yes, its possible. Try looking into MCAnimator (I hope I'm right in saying that this is a modeling and animating tool for modders). Another alternative is to make a series of .JSON models to act like a TextureSprite and loop through those using the getModel() method found in the Item class to return different ModelResourceLocations. Its probably easier to do this in Java, though, using Techne or MCAnimator.
  18. I have my model coded and ready to render, just how do I call the render when I am holding my item? I'm sure I must call this method here on the RenderHandEvent correct?: @Override public void render(Entity par1Entity, float par2Float, float par3Float, float par4Float, float par5Float, float par6Float, float par7Float) { super.render(par1Entity, par2Float, par3Float, par4Float, par5Float, par6Float, par7Float); this.setRotationAngles(par2Float, par3Float, par4Float, par5Float, par6Float, par7Float, par1Entity); this.arm.render(par7Float); } EDIT: Check the post after.
  19. I haven't an idea of how to draw the arm and render it when I want to. All these parameters are confusing me from the ModelPlayer class. Could someone tell me in depth how to specifically do this drawing and rendering (I'm sorry about asking this, I dont have experience with rendering models with Java code, and BTW I'm not asking you to write this code for me)? Is it exactly the same as an entity as in drawing and rendering? As you can quite clearly see, I am very confused, I just need some instructions and directing. Thanks again for being patient with a person who's not so good with the modeling and rendering side of things! EDIT: Figured most of it out, but I still need help on a certain point (not the modeling part).
  20. Thanks, TGG. Yes, I want to draw the player's arm and bind the player's skin to it. The thing is I want to do this while holding my item (this item has a custom model). I've seen people draw quads, then bind the local skin and invoke the rendering when the player holds the item - that is exactly what I need to do. I can do this with .JSON models by making the arm a part of the item with a texture for it - but that's the problem...that's not the player's skin. Basically I just want players to be able to see their personal arm holding the item. With all this, how do I create an arm model, bind the player's skin to it (the part of the texture for the arm), then invoke that rendering when holding my custom item. I don't mind using .JSON modeling for the item, just as long as I can render the arm with it. I hope I wasn't too confusing, I appreciate everyone's help. Thanks!
  21. Thanks for the reply. I thought this as I was finishing some code last night when it was discussed at the beginning of the topic. I'll look into Tile Entities later on.
  22. I hope I'm correct on this, I've done a bit of research - What if I created a model for an item in Techne (or some other tool that exports Java code models), registered it on the ModelBakeEvent with a ModelResourceLocation refering to the model, but how exactly is this model attached to the item to invoke the rendering for the item? Is it done just the same as registering a .JSON model? If I create a model class containing the model code, how is it attached to the item? I've tried to go the simple way of .JSON, but I can't UV the local skin to the model (its an item model with an arm attached to it to make it look like the player is actually holding the item, I just can't get the skin to bind to the arm because its .JSON not java code with the bind local skin method). Any further help is greatly appreciated, thanks!
  23. Thanks for the replies. TGG I had fun playing around with your mod examples in game, haha! These are only examples of .JSON models, correct?
  24. Haha right before you said that I was like "Aww tnt is an entity when primed ". I'm going to keep trying though!
  25. Still not working (going to look in the TNT block class cause I'm also using explosives).
×
×
  • Create New...

Important Information

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