Jump to content

BluSunrize

Members
  • Posts

    7
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

BluSunrize's Achievements

Tree Puncher

Tree Puncher (2/8)

1

Reputation

  1. Minecraft actually tracks the change of armor and equipped items. Due to Armors being able to modify attributes, the method "getAttributeModifiers()" in ItemStack is called, which defers to "getAttributeModifiers(ItemStack stack)" in Item. So by overwriting that method, you can track when the equipment changes. It will not allow you to check if it was equipping or unequipping, or what slot it refers to, and it also wont give you the player, so it's arguably not that useful. However, it is called by "onUpdate()" in EntityLivingBase, and that is something you can emulate. A quick example: I set up a tick handler for player ticks. On tick start, it does the following: if(!player.worldObj.isRemote) { ItemStack[] prevEquipment = getPreviousEquipment(player); if(prevEquipment!=null) for (int j = 0; j < 5; ++j) { ItemStack itemstack = prevEquipment[j]; ItemStack itemstack1 = player.getEquipmentInSlot(j); if (!ItemStack.areItemStacksEqual(itemstack1, itemstack)) changeArmor(player, itemstack, itemstack1); } } the method "getPreviousEquipment(EntityPlayer)" accesses "previousEquipment" in EntityLivingBase via reflection, like this: public static ItemStack[] getPreviousEquipment(EntityLivingBase entity) { int I_prevEquip = 5; Field f = EntityLivingBase.class.getDeclaredFields()[i_prevEquip]; try { f.setAccessible(true); return (ItemStack[]) f.get(entity); } catch (Exception e) { e.printStackTrace(); } return null; } "I_prevEquip" is an integer that represents at which point in the array of declared fields you will find "previousEquipment". One can also find declared fields by name, but that is not obfuscation proof. With this, you'll just have to change the integer when Minecraft updates that class and moves the position of that field (which is generally unlikely) the "setAccessible(true)" is necessary because it is a private and final field. With that you can detect the change in equipment, the method "changeArmor(EntityPlayer, ItemStack, ItemStack)" in my case simply checks if it's my armor that's been moved around and then calls an equip or unequip method in the Item class. lastly, keep in mind that this will detect changing armor but also the changing of the equipped item. Since that is probably something you don't car about, have the for loop start at j=1. That way, you only get the armor slots. If any of that was horribly explained and you didn't understand a thing, I'm sorry =P
  2. Because the recipe is the same, just mirrored? Not sure if that's it, I just noticed that. Give it a try, if it doesn't help, sorry^^
  3. Heyo! I've experimented a bit with events and rendering and decided to tap into the RenderGameOverlayEvent so render an arrow counter for my custom bow. It works by displaying the icon of the arrow over the icon of the bow and is only displayed when the bow is selected. However, when I select the bow, the text in chat and the text displaying what item was selected darkens. I believe that it has something to do with disabling and enabling various GL11 options, but I have been unable to figure out which. The code is as folows: public void render(RenderGameOverlayEvent event) { if(event.isCancelable() || event.type != ElementType.HOTBAR) { return; } ScaledResolution rez = event.resolution; int xPos = 2; int yPos = 2; EntityPlayer player = this.mc.thePlayer; if(player.getCurrentEquippedItem()!=null&&player.getCurrentEquippedItem().itemID==BluTechnology.ItemStandardBow.itemID) { GL11.glPushMatrix(); RenderHelper.enableGUIStandardItemLighting(); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL12.GL_RESCALE_NORMAL); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glEnable(GL11.GL_LIGHTING); GL11.glDisable(GL11.GL_DEPTH_TEST); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); int meta = player.getCurrentEquippedItem().getItemDamage(); //Ignore the method getArrows(), it simply returns an integer of how many arrows of the type are in the inventory of the player ItemStack ammo = new ItemStack(BluTechnology.ItemArrowparts,getArrows(player,meta),meta+1); int hbStart = ((rez.getScaledWidth()/2)-91); itemRenderer.zLevel = 100.0F; itemRenderer.renderItemAndEffectIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, ammo, (player.inventory.currentItem*20)+hbStart+3, rez.getScaledHeight()-54); itemRenderer.renderItemOverlayIntoGUI(this.mc.fontRenderer, this.mc.renderEngine, ammo, (player.inventory.currentItem*20)+hbStart+6, rez.getScaledHeight()-55); GL11.glPopMatrix(); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_DEPTH_TEST); GL11.glDisable(GL11.GL_COLOR_MATERIAL); RenderHelper.enableStandardItemLighting(); } } Anyone see what I'm going for and what I'm doing wrong?
  4. You could try workign with NBT data. Similar to Tile Entities, items(which includes ItemBlocks) can store info as NBT data. You'd have to tap into the function that causes the block to drop and override it so it drops a custom ItemStack which then has a NBTTagCompound assigned to it containing necessary information. That's how ThermalExpansion, for instance, stores the charge and settings on Energy Cells and Tesseracts. With that, everything, including textures for the block can be done via the TileEntity and saved within the NBT of the dropped item, to be later recalled when the block is placed / the TileEntity is initialized.
  5. Allright, it's fixed. I'm now using Forge 8.9.0.771, and the 3rd Person render is there again. Issue resolved.
  6. Hello there. I've had some issues with rendering a 3D model assigned for an item. The ItemRender doesn't seem to work in third person. It renders fine in first person and when another entity is holding it (via the RenderTyes EQUIPPED_FIRST_PERSON and EQUIPPED respectively) but there doesn't appear to be a rendertype for the thrid person view of the own player. I have tried printing out the currently used rendertype, which are EQUIPPED_FIRST_PERSON when in first person and EQUIPPED when looking at a zombie with the item, also obviously INVETORY, since the item needs to be in the Inventory to be selected, but when switching to thrid person, only INVENTORY is printed out, which leads me to believe that there is no rendertype being called for 3rd person item renders of the own player. I'm having that issue with Forge Version 1.6.1-8.9.0.762, dunno if that is fixed with a later version.
  7. Try this: Minecraft.getMinecraft().renderEngine.func_110577_a(new ResourceLocation("DOMAIN:textures/model/TEXTURENAME.png")); The DOMAIN is the foldername before textures basically, make sure it's all lowercase, or you might get some problems. It's similar to the way textures are asigned to items and blocks, with the colon there. What tipped me off was an errormessage in the Eclipse console saying that it couldn't find a texture at "minecraft:/assets/DOMAIN/textures/model/TEXTURENAME.png". So I tried using colons in the designation of the ressource location and: Tada. It worked
×
×
  • Create New...

Important Information

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