Jump to content
  • Home
  • Files
  • Docs
  • Merch
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10][1.8] .getItem() and metadata items
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
PlayPrey

[1.7.10][1.8] .getItem() and metadata items

By PlayPrey, June 29, 2015 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

PlayPrey    0

PlayPrey

PlayPrey    0

  • Tree Puncher
  • PlayPrey
  • Members
  • 0
  • 26 posts
Posted June 29, 2015

Hello once again; Sorry for asking so many questions in a short period of time. :P

 

I have managed to get my mod to detect when something is smelted, however; I can't figure out how to do it with for example charcoal, or cactus green.

 

I tried (prepare to facepalm!)

 

if (e.smelting.getItem() == new ItemStack(Items.coal,1))

{

player.addStat(AE.burnFuel_to_receiveFuel, 1);               

}

 

The error is [incompatible operand types Item and ItemStack]

 

  • Quote

Share this post


Link to post
Share on other sites

larsgerrits    510

larsgerrits

larsgerrits    510

  • Reality Controller
  • larsgerrits
  • Members
  • 510
  • 3455 posts
Posted June 29, 2015

You are trying to compare an Item to an ItemStack (hence the error). You have to check the Item first (

ItemStack#getItem()

==

Items.coal

), and then the metadata (

ItemStack#getItemDamage()

== 1).

 

PS, I think

ItemStack#getItemDamage()

is called

ItemStack#getMetadata()

in MC 1.8.

  • Quote

Share this post


Link to post
Share on other sites

diesieben07    6692

diesieben07

diesieben07    6692

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6692
  • 45730 posts
Posted June 29, 2015

Didn't you mention in your other thread that you have like 3 years of experience with programming in Java? Then this should not be a problem that confuses you like... at all. If it does I seriously wonder how you spent those 3 years.

 

To also check the metadata, well, also check the metadata. First check the Item like normal and then additionally check if the metadata is correct.

  • Quote

Share this post


Link to post
Share on other sites

PlayPrey    0

PlayPrey

PlayPrey    0

  • Tree Puncher
  • PlayPrey
  • Members
  • 0
  • 26 posts
Posted June 29, 2015

Thank you! :) It now works flawlessly :)

 

Also; diesieben07 ; I tried to say I had NOT touched Java since 2012 - So stuff is a little difficult to begin with. Im sorry about this. :P

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

  • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 0
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • TomPlayzs
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By TomPlayzs · Posted 19 minutes ago

      I have this problem too! How do i fix it?
    • Oliviafrostpaw
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw · Posted 30 minutes ago

      Making it easier for showing the code, please see GitHub repository that I ideally should have set up to begin with so that I would have known when exactly all of this broke Github Link
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      i think whoever's bugging me in the HorseEntity Class is, here: private static final String[] HORSE_TEXTURES = new String[]{"textures/entity/horse/horse_white.png", "textures/entity/horse/horse_creamy.png", "textures/entity/horse/horse_chestnut.png", "textures/entity/horse/horse_brown.png", "textures/entity/horse/horse_black.png", "textures/entity/horse/horse_gray.png", "textures/entity/horse/horse_darkbrown.png"};  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.client.models; import net.minecraft.client.renderer.entity.model.EntityModel; import net.minecraft.client.renderer.entity.model.RendererModel; import net.minecraft.client.renderer.model.ModelBox; import net.minecraft.entity.LivingEntity; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @OnlyIn(Dist.CLIENT) public class ModelUnicornWitoutAbstracHorse<T extends LivingEntity> extends EntityModel<T> { protected final RendererModel field_217127_a; protected final RendererModel field_217128_b; private final RendererModel CornGroup; private final RendererModel Corn1; private final RendererModel Corn2; private final RendererModel Corn3; public ModelUnicornWitoutAbstracHorse(float p_i51065_1_) { this.field_217127_a = null; this.field_217128_b = null; this.textureWidth = 128; this.textureHeight = 64; CornGroup = new RendererModel(this); CornGroup.setRotationPoint(0.0F, 0.0F, 0.0F); Corn1 = new RendererModel(this, 64, 0); Corn1.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn1.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn1); Corn1.cubeList.add(new ModelBox(Corn1, 52, 57, -3.0F, -3.0F, -4.0F, 3, 4, 3, 0.0F, true)); Corn2 = new RendererModel(this, 64, 28); Corn2.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn2.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn2); Corn2.cubeList.add(new ModelBox(Corn2, 0, 0, -2.4F, -5.3F, -3.6F, 2, 3, 2, 0.0F, true)); Corn3 = new RendererModel(this, 96, 32); Corn3.setRotationPoint(1.5F, -5.0F, -15.0F); this.Corn3.setRotationPoint(0.5409F, 0.0F, 0.0F); CornGroup.addChild(Corn3); Corn3.cubeList.add(new ModelBox(Corn3, 0, 0, -1.8F, -8.1F, -3.2F, 1, 3, 1, 0.0F, true)); } protected void func_199047_a(RendererModel p_199047_1_) { RendererModel renderermodel = new RendererModel(this, 19, 16); renderermodel.addBox(0.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); RendererModel renderermodel1 = new RendererModel(this, 19, 16); renderermodel1.addBox(-2.55F, -13.0F, 4.0F, 2, 3, 1, -0.001F); p_199047_1_.addChild(renderermodel); p_199047_1_.addChild(renderermodel1); } }  
    • DragonITA
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA · Posted 1 hour ago

      package net.batonfack.fantasymod.entities; import net.batonfack.fantasymod.init.FantasyModEntities; import net.minecraft.entity.EntityType; import net.minecraft.entity.passive.horse.HorseEntity; import net.minecraft.world.World; public class UnicornEntity extends HorseEntity { @SuppressWarnings("unchecked") public UnicornEntity(EntityType<? extends HorseEntity> type, World worldIn) { super((EntityType<? extends HorseEntity>) FantasyModEntities.UNICORN_ENTITY, worldIn); } }  
  • Topics

    • WinneonSword
      2
      [ solved ] - HUD images (exp bar, health, hunger, etc.) glitching out.

      By WinneonSword
      Started August 31, 2013

    • Oliviafrostpaw
      8
      [1.14.4] Injecting into Existing Loot Tables, Blocks

      By Oliviafrostpaw
      Started December 8

    • DragonITA
      40
      [1.14.4] How to get Minecraft Horse model/texture to make a custom unicorn?

      By DragonITA
      Started Monday at 10:06 AM

    • DarkZapato
      2
      Optifine 1.14.4 U HD F4 crash froge

      By DarkZapato
      Started Thursday at 04:09 PM

    • troyvs
      0
      [1.12.2]help me to attach capability to player

      By troyvs
      Started 1 hour ago

  • Who's Online (See full list)

    • TolgacanM
    • Choonster
    • Misterboy64
    • Yanny7
    • ricoc90
    • Oliviafrostpaw
    • TomPlayzs
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.7.10][1.8] .getItem() and metadata items
  • Theme
  • Contact Us
  • Discord

Copyright © 2019 ForgeDevelopment LLC · Ads by Curse Powered by Invision Community