Jump to content

Hunternif

Members
  • Posts

    36
  • Joined

  • Last visited

Everything posted by Hunternif

  1. Here: http://www.minecraftforge.net/wiki/Custom_2D_Inventory_Item_Renderer *ENGINEER IS CREDIT TO TEAM*
  2. Thanks for the reply, Kore! I thought I had to do everything that is not rendering (and changing itemStack's damage surely is not) BOTH on the server and the client. But I tried your suggestion and added this check to CooldownItem.onUpdate(...), and the game still worked properly. However, the jerking item issue was not solved. It even seemed like the item was spending more time in a "lowered" position than before. Although that looked a bit better than a "full" up-and-down swing
  3. Nvm, figured it out. Will post solution later. Maybe I'll make a wiki too
  4. I made a custom IItemRenderer implementation to render items in inventory slots. Now I need to draw a simple 2D polygonal shape in the inventory item slot. The javadoc says: So I thought the code should look something like this: // Draw a semi-transparent red square GL11.glColor4f(1.0f, 0f, 0f, 0.5f); GL11.glBegin(GL11.GL_QUADS); GL11.glVertex3f(0F, 0F, 0F); GL11.glVertex3f(16F, 0F, 0F); GL11.glVertex3f(16F, 16F, 0F); GL11.glVertex3f(0F, 16F, 0F); GL11.glEnd(); But nothing appears in the item slot. Can anyone help me with this?
  5. After a bit more research, I can add that the desynchronization of itemStacks in method updateEquippedItems() happens because of Container.detectAndSendChanges()
  6. I am trying to implement cooldown for my items (CooldownItem extends Item), and it seems like ItemStack.itemDamage is the only place where I can store the cooldown time, so that it is correctly shared between client and server and is remembered when the itemStack is moved/dropped/etc. Once the cooldown starts, I set itemDamage to the respective itemStack, and then on each tick in the CooldownItem.onUpdate(...) method I decrease this itemStack's itemDamage by 1. Now the problem happens in ItemRenderer.updateEquippedItems(): probably because the itemStacks' damage is updated EVERY tick, it can get out of sync between different itemStacks that were copied. In the method I mentioned above the item that the player is currently holding in his hand gets out of sync with some other ItemStack reference to the same item because their itemDamage values are off by a small amount, and unequip animation starts. On some other tick they get in sync again and equip animation starts. So while my item is on cooldown and the player is holding it, it jerks up and down in a really annoying fashion. Perhaps this could even be regarded as a bug in Minecraft, since ItemRenderer is located in package net.minecraft.client.renderer. But there are no items in Minecraft that get damaged constantly while no one uses them, like my CooldownItem. I thought about storing cooldown in some other place, like make a Map<ItemStack, Integer> in CooldownItem, but then sharing the cooldown between copied itemStacks and between client and server seems like it's going to be a real pain to code. I can't subclass ItemStack, because it's declared final. Anyone got ideas how to fix my rendering issue?
  7. In RenderItem.renderItemAndEffectIntoGUI(...) there is a call to ForgeHooksClient.renderInventoryItem(...), but in RenderItem.renderItemOverlayIntoGUI(...) there is no such hook. This could be useful when drawing additional info (like a text string) overlayed on items in inventory, without changing the code where the item texture is rendered. I suppose this will need a method ForgeHooksClient.renderInventoryItemOverlay(...) and a new type ItemRenderType.INVENTORY_OVERLAY Maybe I'll pull-request it myself sometime.
×
×
  • Create New...

Important Information

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