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

[Bug]: the player loses the block when placing it if the protected area is not his #28

Closed
5 tasks done
Misaass opened this issue Oct 8, 2023 · 1 comment
Closed
5 tasks done
Labels
bug Something isn't working

Comments

@Misaass
Copy link

Misaass commented Oct 8, 2023

Bug Description

modify the mod in the blockPlace mixin to prevent that from happening, it would be a good feature since it should not remove the block from the player

private void place(BlockPlaceContext blockPlaceContext, CallbackInfoReturnable<InteractionResult> cir) {


        if (!ClaimApi.API.canPlaceBlock(blockPlaceContext.getLevel(), blockPlaceContext.getClickedPos(), blockPlaceContext.getPlayer())) {

            Player playerPlaced = null;

            if(blockPlaceContext.getPlayer() != null) {
                playerPlaced = blockPlaceContext.getPlayer();

                int slot = playerPlaced.getInventory().selected;

                ItemStack stack = playerPlaced.getInventory().getItem(slot);

                cir.setReturnValue(InteractionResult.FAIL);

                blockPlaceContext.getPlayer().getInventory().setItem(slot, stack.copy());
            }
            else {
                cir.setReturnValue(InteractionResult.FAIL);
            }
        }
    }

How to Reproduce?

No response

Expected Behavior

No response

Version

1.0.0

Mod Loader Version

1.20.x

Mod Loader

Fabric

Logs or additional context

No response

Code of Conduct

  • I have searched the issue tracker and confirmed that the issue has not been reported
  • I have checked the FAQ (if one is present) and my issue is not listed
  • I have verified that I am using the latest version of the mod
  • I have verified that I have installed all the required dependencies for the mod
  • I have verified that I do not have Optifine installed. We will close issues if we detect Optifine is in your pack. We cannot fix Optifine issues. Please do not report issues with Optifine present.
@Misaass Misaass added the bug Something isn't working label Oct 8, 2023
@CodexAdrian
Copy link
Member

The block isnt consumed in my testing, please verify it isnt a client desync issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants