### Restricting Brewing with Potion Components Source: https://context7.com/daqem/itemrestrictions/llms.txt Example of restricting specific potions, including their NBT/component data, for precise brewing restrictions. ```APIDOC ## Restricting Brewing with Potion Components Restrict specific potions including their NBT/component data for precise brewing restrictions. ### Example Restriction JSON ```json { "icon": { "id": "minecraft:potion", "count": 1, "components": { "minecraft:potion_contents": { "potion": "minecraft:swiftness" } } }, "types": [ "brew" ], "conditions": [ { "type": "arc:item", "item": { "id": "minecraft:potion", "count": 1, "components": { "minecraft:potion_contents": { "potion": "minecraft:swiftness" } } } } ] } ``` ``` -------------------------------- ### Basic Restriction JSON Structure Source: https://context7.com/daqem/itemrestrictions/llms.txt A fundamental example of an Item Restrictions JSON file. It specifies an icon, the types of restrictions applied, and a condition that must be met for the restriction to be active. ```json { "icon": { "id": "minecraft:diamond_sword" }, "types": [ "craft", "enchant", "repair", "use_item", "hurt_entity" ], "conditions": [ { "type": "arc:item", "check_components": false, "item": { "id": "minecraft:diamond_sword" } } ], "client_side": true } ``` -------------------------------- ### Custom Restriction Example: No Elytra Source: https://context7.com/daqem/itemrestrictions/llms.txt This JSON defines a custom restriction for the elytra, preventing its use. It specifies the item, the action type ('use_item'), and can be marked as client-side. ```json // config/itemrestrictions/restrictions/myserver/no_elytra.json { "icon": { "id": "minecraft:elytra" }, "types": [ "use_item" ], "conditions": [ { "type": "arc:item", "item": { "id": "minecraft:elytra" } } ], "client_side": true } ``` -------------------------------- ### Conditional Restrictions Based on Equipment Source: https://context7.com/daqem/itemrestrictions/llms.txt An example of a conditional restriction that applies unless a specific item is equipped. The 'inverted: true' flag negates the condition, meaning the restriction is active when the player is NOT wearing the specified item. ```json { "icon": { "id": "minecraft:copper_pickaxe" }, "types": [ "craft", "smelt", "enchant", "repair", "item_break_block", "hurt_entity" ], "conditions": [ { "type": "arc:item", "check_components": false, "item": { "id": "minecraft:copper_pickaxe" } }, { "type": "arc:item_equipped", "inverted": true, "item": { "id": "minecraft:copper_helmet" } } ] } ``` -------------------------------- ### Access ItemRestrictionManager API Source: https://context7.com/daqem/itemrestrictions/llms.txt Use the ItemRestrictionManager class to programmatically access and manage loaded restrictions. Obtain the singleton instance, retrieve all restrictions, or get a specific one by its identifier. ```java // Get the singleton instance of the restriction manager ItemRestrictionManager manager = ItemRestrictionManager.getInstance(); ``` ```java // Get all loaded restrictions List restrictions = manager.getItemRestrictions(); ``` ```java // Get a specific restriction by its identifier Identifier location = Identifier.fromNamespaceAndPath("mymod", "diamond_tools"); ItemRestriction restriction = manager.getItemRestriction(location); ``` ```java // Programmatically set restrictions (typically done via networking from server) List newRestrictions = new ArrayList<>(); newRestrictions.add(customRestriction); manager.setItemRestrictions(newRestrictions); ``` -------------------------------- ### Configuration File Structure Source: https://context7.com/daqem/itemrestrictions/llms.txt Details on the YAML configuration file for excluding restrictions. ```APIDOC ## Configuration File The mod uses a YAML configuration file located at `config/itemrestrictions/item-restrictions-common.yaml` to exclude specific restrictions. ### `config/itemrestrictions/item-restrictions-common.yaml` ```yaml # config/itemrestrictions/item-restrictions-common.yaml restrictions: # A list of restriction IDs to exclude from the game # Example: ['mymod:diamond_tools', 'othermod:netherite_armor'] excluded_restrictions: [] ``` ``` -------------------------------- ### Custom Restrictions via Config Folder Source: https://context7.com/daqem/itemrestrictions/llms.txt Instructions for adding custom restriction JSON files to the configuration. ```APIDOC ## Custom Restrictions via Config Folder Place custom restriction JSON files in `config/itemrestrictions/restrictions//.json` for restrictions that persist across world saves. ### Directory Structure Example ``` config/ itemrestrictions/ item-restrictions-common.yaml restrictions/ myserver/ no_elytra.json progression_tools.json minecraft/ override_vanilla.json ``` ### Example Custom Restriction JSON (`no_elytra.json`) ```json // config/itemrestrictions/restrictions/myserver/no_elytra.json { "icon": { "id": "minecraft:elytra" }, "types": [ "use_item" ], "conditions": [ { "type": "arc:item", "item": { "id": "minecraft:elytra" } } ], "client_side": true } ``` ``` -------------------------------- ### Define Custom Restrictions in Config Folder Source: https://context7.com/daqem/itemrestrictions/llms.txt Place custom restriction JSON files in `config/itemrestrictions/restrictions//.json` to define restrictions that persist across world saves. ```directory config/ itemrestrictions/ item-restrictions-common.yaml restrictions/ myserver/ no_elytra.json progression_tools.json minecraft/ override_vanilla.json ``` -------------------------------- ### Exclude Restrictions via Common Configuration Source: https://context7.com/daqem/itemrestrictions/llms.txt Configure the mod using a YAML file located at `config/itemrestrictions/item-restrictions-common.yaml` to exclude specific restriction IDs from being loaded. ```yaml # config/itemrestrictions/item-restrictions-common.yaml restrictions: # A list of restriction IDs to exclude from the game # Example: ['mymod:diamond_tools', 'othermod:netherite_armor'] excluded_restrictions: [] ``` -------------------------------- ### Checking Restrictions Programmatically Source: https://context7.com/daqem/itemrestrictions/llms.txt Utilize the `ItemRestrictionsPlayer` interface to determine if actions are restricted for a player. ```APIDOC ## Checking Restrictions Programmatically Use the `ItemRestrictionsPlayer` interface to check if actions are restricted for a player. ### Example: Checking Block Break Restriction ```java public EventResult onBlockBreak(ServerLevel level, BlockPos pos, BlockState state, ServerPlayer player) { if (player instanceof ItemRestrictionsPlayer restrictionsPlayer && player instanceof ArcServerPlayer arcPlayer) { // Build action data with context about the action ActionData actionData = new ActionDataBuilder(arcPlayer, null) .withData(IActionDataType.ITEM_STACK, state.getBlock().asItem().getDefaultInstance()) .withData(IActionDataType.ITEM, state.getBlock().asItem()) .withData(IActionDataType.BLOCK_STATE, state) .withData(IActionDataType.BLOCK_POSITION, pos) .withData(IActionDataType.WORLD, level) .build(); // Check restriction RestrictionResult result = restrictionsPlayer.itemrestrictions$isRestricted(actionData); if (result.isRestricted(RestrictionType.BREAK_BLOCK)) { player.sendSystemMessage( ItemRestrictions.API.translatable(RestrictionType.BREAK_BLOCK.getTranslationKey()) .withStyle(ChatFormatting.RED), true ); return EventResult.INTERRUPT_FALSE; } } return EventResult.PASS; } ``` ``` -------------------------------- ### Check Player Restrictions Programmatically Source: https://context7.com/daqem/itemrestrictions/llms.txt Implement the ItemRestrictionsPlayer interface to check if actions are restricted for a player. Build ActionData with context and use itemrestrictions$isRestricted to determine restriction status. ```java // Check if a player action is restricted public EventResult onBlockBreak(ServerLevel level, BlockPos pos, BlockState state, ServerPlayer player) { if (player instanceof ItemRestrictionsPlayer restrictionsPlayer && player instanceof ArcServerPlayer arcPlayer) { // Build action data with context about the action ActionData actionData = new ActionDataBuilder(arcPlayer, null) .withData(IActionDataType.ITEM_STACK, state.getBlock().asItem().getDefaultInstance()) .withData(IActionDataType.ITEM, state.getBlock().asItem()) .withData(IActionDataType.BLOCK_STATE, state) .withData(IActionDataType.BLOCK_POSITION, pos) .withData(IActionDataType.WORLD, level) .build(); // Check restriction RestrictionResult result = restrictionsPlayer.itemrestrictions$isRestricted(actionData); if (result.isRestricted(RestrictionType.BREAK_BLOCK)) { player.sendSystemMessage( ItemRestrictions.API.translatable(RestrictionType.BREAK_BLOCK.getTranslationKey()) .withStyle(ChatFormatting.RED), true ); return EventResult.INTERRUPT_FALSE; } } return EventResult.PASS; } ``` -------------------------------- ### Restrict Specific Potions with NBT/Component Data Source: https://context7.com/daqem/itemrestrictions/llms.txt Use this JSON structure to define restrictions for specific potions, including their NBT or component data, for precise brewing control. ```json { "icon": { "id": "minecraft:potion", "count": 1, "components": { "minecraft:potion_contents": { "potion": "minecraft:swiftness" } } }, "types": [ "brew" ], "conditions": [ { "type": "arc:item", "item": { "id": "minecraft:potion", "count": 1, "components": { "minecraft:potion_contents": { "potion": "minecraft:swiftness" } } } } ] } ``` -------------------------------- ### Restricting Multiple Items with OR Condition Source: https://context7.com/daqem/itemrestrictions/llms.txt Demonstrates how to apply a set of restrictions to multiple items, blocks, or entity types using the 'arc:or' condition. This allows for broader restriction rules. ```json { "icon": { "id": "minecraft:stone" }, "types": [ "craft", "smelt", "enchant", "repair", "use_item", "break_block", "item_break_block", "place_block", "hurt_entity", "interact_entity", "interact_block" ], "conditions": [ { "type": "arc:or", "conditions": [ { "type": "arc:items", "items": [ "minecraft:stone", "minecraft:stone_bricks", "minecraft:egg", "minecraft:cooked_beef", "minecraft:diamond_sword" ] }, { "type": "arc:block", "block": "minecraft:furnace" }, { "type": "arc:entity_type", "entity_type": "minecraft:cow" } ] } ] } ``` -------------------------------- ### ItemRestrictionManager API Source: https://context7.com/daqem/itemrestrictions/llms.txt Provides methods to access and manage loaded item restrictions programmatically. ```APIDOC ## ItemRestrictionManager API The `ItemRestrictionManager` class provides methods to access and manage loaded restrictions programmatically. ### Get Singleton Instance ```java ItemRestrictionManager manager = ItemRestrictionManager.getInstance(); ``` ### Get All Loaded Restrictions ```java List restrictions = manager.getItemRestrictions(); ``` ### Get Specific Restriction by Identifier ```java Identifier location = Identifier.fromNamespaceAndPath("mymod", "diamond_tools"); ItemRestriction restriction = manager.getItemRestriction(location); ``` ### Programmatically Set Restrictions ```java List newRestrictions = new ArrayList<>(); newRestrictions.add(customRestriction); manager.setItemRestrictions(newRestrictions); ``` ``` -------------------------------- ### Available Restriction Types Enum Source: https://context7.com/daqem/itemrestrictions/llms.txt Defines the different types of interactions that can be restricted. Each type corresponds to a specific player action. ```java public enum RestrictionType { CRAFT("cant_craft"), // Prevent crafting the item SMELT("cant_smelt"), // Prevent smelting the item in furnaces BREW("cant_brew"), // Prevent brewing the item ENCHANT("cant_enchant"), // Prevent enchanting the item REPAIR("cant_repair"), // Prevent repairing the item (anvil) USE_ITEM("cant_use_item"), // Prevent using/activating the item BREAK_BLOCK("cant_break_block"), // Prevent breaking a specific block ITEM_BREAK_BLOCK("cant_item_break_block"), // Prevent using item to break blocks PLACE_BLOCK("cant_place_block"), // Prevent placing a block HURT_ENTITY("cant_hurt_entity"), // Prevent damaging entities with item INTERACT_ENTITY("cant_interact_entity"), // Prevent interacting with entities INTERACT_BLOCK("cant_interact_block"), // Prevent interacting with blocks NONE(""); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.