Enchanting Infuser [Forge & Fabric]

Enchanting Infuser [Forge & Fabric]

3M Downloads

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

RulsOfficial opened this issue · 2 comments

commented

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 ?

commented

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) {

commented

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; }