Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item method shouldCauseBlockBreakReset does not work when itemStack::hurt #9906

Open
LIUKRAST opened this issue Apr 13, 2024 · 2 comments
Open
Labels
Triage This request requires the active attention of the Triage Team. Requires labelling or reviews.

Comments

@LIUKRAST
Copy link

LIUKRAST commented Apr 13, 2024

Minecraft Version: 1.20.1

Forge Version: 47.2.20

I'm overriding these methods in my custom item

    @Override
    public void inventoryTick(ItemStack pStack, Level pLevel, Entity pEntity, int pSlotId, boolean pIsSelected) {
        if(pIsSelected) {
            if (!pLevel.isClientSide && pEntity instanceof LivingEntity entity) {
                pStack.hurtAndBreak(1, entity, (p_40992_) -> p_40992_.broadcastBreakEvent(EquipmentSlot.MAINHAND));
            }
        }
        super.inventoryTick(pStack, pLevel, pEntity, pSlotId, pIsSelected);
    }

    @Override
    public boolean shouldCauseBlockBreakReset(ItemStack oldStack, ItemStack newStack) {
        return oldStack.getItem() != newStack.getItem();
    }

which returns false cause sameDestroyTarget(BlockPos pos) in MultiPlayerGameMode has an && gate with
ItemStack.isSameItemSameTags(itemstack, this.destroyingItem), which for some reason is false.

Not sure if this is a bug, but i thought about reporting it anyways!

@LIUKRAST LIUKRAST added the Triage This request requires the active attention of the Triage Team. Requires labelling or reviews. label Apr 13, 2024
@LexManos
Copy link
Member

You're right that is a messed up patch, the isSameItemSameTags should be removed. As the shouldCaueBlockBreakReset is the replacement for that method.

@LIUKRAST
Copy link
Author

The method shouldCauseBlockBreakReset calls the tags check...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Triage This request requires the active attention of the Triage Team. Requires labelling or reviews.
Projects
None yet
Development

No branches or pull requests

2 participants