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

How can i limit the infuser to only work with player in a scpecific team ? #89

Closed
RulsOfficial opened this issue Apr 15, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@RulsOfficial
Copy link

Mod Loader (Optional)

Minecraft Version(s) (Optional)

1.20.1

Mod Version(s) (Optional)

No response

Suggestion (Required)

I usually go to the screen or tab and edit the method to open the gui of the block with:

if (MinecraftClient.getInstance().player != null && MinecraftClient.getInstance().player.getScoreboardTeam() != null && MinecraftClient.getInstance().player.getScoreboardTeam().getName().equals("Team"))

but no mater what i do it doesnt work with this mod, is there any easy way i can do it ?

@RulsOfficial RulsOfficial added the enhancement New feature or request label Apr 15, 2024
@Fuzss
Copy link
Owner

Fuzss commented Apr 15, 2024

You want to hook in here and use the player from that.

public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand interactionHand, BlockHitResult hitResult) {

@Fuzss Fuzss closed this as completed Apr 15, 2024
@RulsOfficial
Copy link
Author

RulsOfficial commented Apr 15, 2024

Thats what i though, but it doesnt seem to work and java struggles to find the simbols, here is my code:

@Override public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand interactionHand, BlockHitResult hitResult) { if (player.getScoreboardTeam() != null && player.getScoreboardTeam().getName().equals("Enchanter")) { if (level.getBlockEntity(pos) instanceof InfuserBlockEntity blockEntity) { if (!level.isClientSide) { player.openMenu(state.getMenuProvider(level, pos)); // items might still be in inventory slots, so this needs to update so that enchantment buttons are shown player.containerMenu.slotsChanged(blockEntity); } return InteractionResult.sidedSuccess(level.isClientSide); } return InteractionResult.PASS; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants