GregTech CE Unofficial

GregTech CE Unofficial

412k Downloads

[BUG] Log spam with invalid warning on getHarvestLevel()

LemADEC opened this issue ยท 6 comments

commented

Describe the bug
toolMetaItem.getHarvestLevel is spamming logs whenever it's called with a NULL IBlockState while the forge definition allows said parameter to be nullable.

Versions
Forge: 1.12.2-14.23.5.2847
GTCEu: 1.12.2-2.1.4
Modpack: not applicable
Addons: WarpDrive 1.12.2-1.5.25

Setup
Does this issue happen on Singleplayer, a Server, or both: both
Does this issue happen on a newly generated world: yes

Steps To Reproduce

  1. pickup an Hammer
  2. open inventory and check the tooltip

Expected behavior
No log spam, actually return the tool harvest level without doing the block check part

Additional context
Forge source code for Item class:

public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState)
commented
[15:05:18] [Client thread/WARN] [GregTech]: ToolMetaItem.getHarvestLevel called for tool 'cutter' without providing IBlockState. Offending stack trace:
    gregtech.api.items.toolitem.ToolMetaItem.getHarvestLevel(ToolMetaItem.java:279)
    cr0s.warpdrive.event.TooltipHandler.addItemDetails(TooltipHandler.java:464)
    cr0s.warpdrive.event.TooltipHandler.onTooltipEvent_last(TooltipHandler.java:98)
    net.minecraftforge.fml.common.eventhandler.ASMEventHandler_1268_TooltipHandler_onTooltipEvent_last_ItemTooltipEvent.invoke(.dynamic)
    net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    net.minecraftforge.event.ForgeEventFactory.onItemTooltip(ForgeEventFactory.java:358)
    net.minecraft.item.ItemStack.func_82840_a(ItemStack.java:889)
    net.minecraft.client.gui.GuiScreen.func_191927_a(GuiScreen.java:143)
    net.minecraft.client.gui.GuiScreen.func_146285_a(GuiScreen.java:137)
    net.minecraft.client.gui.inventory.GuiContainerCreative.func_146285_a(GuiContainerCreative.java:737)
    net.minecraft.client.gui.inventory.GuiContainer.func_191948_b(GuiContainer.java:175)
    net.minecraft.client.gui.inventory.GuiContainerCreative.func_73863_a(GuiContainerCreative.java:684)
    net.minecraftforge.client.ForgeHooksClient.drawScreen(ForgeHooksClient.java:396)
    net.minecraft.client.renderer.EntityRenderer.func_181560_a(EntityRenderer.java:1124)
    net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1119)
    net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:3942)
    net.minecraft.client.main.Main.main(SourceFile:123)
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    java.lang.reflect.Method.invoke(Method.java:497)
    net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    net.minecraft.launchwrapper.Launch.main(Launch.java:28)
commented

log pls

commented

Updated the misleading bug description: issue happens when passing a NULL IBlockState.

commented

Does this still happen?

commented

Yes, the bug is still there in GTCE, as seen here: https://github.com/GregTechCEu/GregTech/blob/master/src/main/java/gregtech/api/items/toolitem/ToolMetaItem.java#L278
IBlockstate is nullable in this context.

commented

This is not a bug but limitation of current implementation of Tools.

This will be fixed by #690