Jump to content

[1.18.2] how to check what item is on the ground


tobywig

Recommended Posts

ItemEntity.getItem()

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

Link to comment
Share on other sites

  • tobywig changed the title to [1.18.2] how to check what item is on the ground

You really need to teach yourself how java works.

This is very basic stuff.  You need to be able to understand what the compiler is telling you.

You can't just post the error message here and expect others to fix it for you.

Especially when you don't even show the java code.

Anyway (untested pseudo code):

Entity entity = // from wherever
if (entity instanceof ItemEntity itemEntity) {
    ItemStack itemStack = itemEntity.getItem();
    if (itemStack.getItem() == Items.IRON_INGOT) {
        // Do stuff
    }
}

Usually it is better to define an item tag rather than hard wiring items in your code.

Also note an ItemEntity contains an ItemStack of items, not just 1 item.

 

Edited by warjort

Boilerplate:

If you don't post your logs/debug.log we can't help you. For curseforge you need to enable the forge debug.log in its minecraft settings. You should also post your crash report if you have one.

If there is no error in the log file and you don't have a crash report then post the launcher_log.txt from the minecraft folder. Again for curseforge this will be in your curseforge/minecraft/Install

Large files should be posted to a file sharing site like https://gist.github.com  You should also read the support forum sticky post.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • So, ive seen this issue before, and i've deleted the forge-client.toml file already, because the part in other issues closely related to this, but this seems to be new to me. everytime it loads everything in the forge menu, it then says loading minecraft, and as it gets to the home page, it crashes, and it states this in the crash report. "the game crashed while rendering overlay. Error: java.lang.ExceptionInInitializerError: null" 
    • So I tried to search the issue but came up with nothing, the most I could get was some people having a mod location between the colon and the word "failed" but I seem to have nothing there. I am also making a modpack of my own, and tips are appreciated!
    • Heres a updated version of my github https://github.com/THEKINGSKULL01/TSOTD0.0.30Forge1.20.1
    • When i go to the forge website to download any of the choices of versions I am unable to download anything. It just says that I am unable to reach this website for some reason.
    • hi everyone how can i make this script smoother or make them delay    @SubscribeEvent(       priority = EventPriority.HIGH    )    public void renderCrosshair(RenderGameOverlayEvent event) {       if(mc.gameSettings.guiScale == 2) {       Minecraft minecraft = Minecraft.getMinecraft();       if(event.type == ElementType.CROSSHAIRS && isGunInHand(minecraft.thePlayer)) {          event.setCanceled(true);          Icon crosshairIcon = ClientProxy.iconRegistry.crosshairIcon;          double scale = 6.0F + getScaleByMotion(minecraft.thePlayer);          if(FlansModClient.currentScope == null)          scale = 45.0F + getScaleByMotion(minecraft.thePlayer);                    GL11.glPushAttrib(16384);          GL11.glPushMatrix();          GL11.glEnable(3042);          OpenGlHelper.glBlendFunc(775, 769, 1, 0);          GL11.glEnable(3008);          GL11.glColor3d(1.0D, 1.0D, 1.0D);          GL11.glTranslated((double)(event.resolution.getScaledWidth() / 2), (double)(event.resolution.getScaledHeight() / 2), 0.0D);          GL11.glPushMatrix();          ClientProxy.iconRegistry.bindSheet();          GL11.glRotated(90.0D, 0.0D, 0.0D, 2.0D);          ClientProxy.iconRegistry.renderIcon(crosshairIcon, -1.9D, (double)(-scale) + 0.1D);          GL11.glRotated(90.0D, 0.0D, 0.0D, 1.0D);          ClientProxy.iconRegistry.renderIcon(crosshairIcon, -3.0D, (double)(-scale) - 0.1D);          GL11.glRotated(90.0D, 0.0D, 0.0D, 1.0D);          ClientProxy.iconRegistry.renderIcon(crosshairIcon, -3.0D, (double)(-scale) + 0.9D);                    if(FlansModClient.currentScope == null)                        {          GL11.glRotated(90.0D, 0.0D, 0.0D, 1.0D);          ClientProxy.iconRegistry.renderIcon(crosshairIcon, -2.1D, (double)(-scale) + 0.9D);          }                    else if (scale >= 6.5F)          {          GL11.glRotated(90.0D, 0.0D, 0.0D, 1.0D);          ClientProxy.iconRegistry.renderIcon(crosshairIcon, -2.1D, (double)(-scale) + 0.9D);          }                    GL11.glPopMatrix();          GL11.glPopMatrix();          GL11.glPopAttrib();          minecraft.getTextureManager().bindTexture(Gui.icons);       }       }    }
  • Topics

×
×
  • Create New...

Important Information

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