From d1ea5a1f80cdcebf65e41b7b8df15eb8e31fe450 Mon Sep 17 00:00:00 2001 From: ChampionAsh5357 Date: Mon, 14 Oct 2024 00:58:49 -0400 Subject: [PATCH 01/44] chore(docs): Apply contributing formating --- docs/advanced/_category_.json | 4 +- docs/advanced/accesstransformers.md | 14 +- docs/advanced/extensibleenums.md | 6 +- docs/blockentities/_category_.json | 4 +- docs/blockentities/container.md | 2 +- docs/blocks/_category_.json | 4 +- docs/concepts/_category_.json | 4 +- docs/datastorage/_category_.json | 4 +- docs/datastorage/attachments.md | 2 +- docs/datastorage/nbt.md | 2 +- docs/datastorage/saveddata.md | 8 +- docs/gettingstarted/_category_.json | 4 +- docs/gui/_category_.json | 4 +- docs/gui/menus.md | 212 ++--- docs/items/_category_.json | 4 +- .../{datacomponents.mdx => datacomponents.md} | 0 docs/items/index.md | 51 +- docs/items/mobeffects.md | 2 +- docs/items/tools.md | 30 +- docs/legacy/_category_.json | 4 +- docs/misc/_category_.json | 4 +- docs/misc/{gametest.mdx => gametest.md} | 90 +- docs/misc/keymappings.md | 52 +- docs/misc/updatechecker.md | 26 +- docs/networking/_category_.json | 4 +- docs/resources/_category_.json | 4 +- docs/resources/client/_category_.json | 2 +- docs/resources/client/i18n.md | 4 +- docs/resources/client/models/modelloaders.md | 2 +- docs/resources/index.md | 10 +- docs/resources/server/_category_.json | 2 +- docs/resources/server/advancements.md | 24 +- docs/resources/server/conditions.md | 106 +-- docs/resources/server/damagetypes.md | 34 +- docs/resources/server/datamaps/builtin.md | 140 ++-- docs/resources/server/datamaps/index.md | 142 ++-- docs/resources/server/enchantments/builtin.md | 126 +-- docs/resources/server/enchantments/index.md | 234 +++--- docs/resources/server/loottables/glm.md | 38 +- docs/resources/server/loottables/index.md | 64 +- .../server/loottables/lootconditions.md | 296 +++---- .../server/loottables/lootfunctions.md | 776 +++++++++--------- docs/resources/server/recipes/builtin.md | 156 ++-- docs/resources/server/recipes/index.md | 8 +- docs/resources/server/recipes/ingredients.md | 18 +- docs/resources/server/tags.md | 102 +-- docs/worldgen/_category_.json | 4 +- docs/worldgen/biomemodifier.md | 280 +++---- .../configuration/{index.mdx => index.md} | 0 neogradle_versions.json | 4 +- .../{contributing.mdx => contributing.md} | 2 - src/pages/index.md | 33 + src/pages/index.mdx | 33 - 53 files changed, 1597 insertions(+), 1588 deletions(-) rename docs/items/{datacomponents.mdx => datacomponents.md} (100%) rename docs/misc/{gametest.mdx => gametest.md} (87%) rename neogradle/docs/configuration/{index.mdx => index.md} (100%) rename src/pages/{contributing.mdx => contributing.md} (99%) create mode 100644 src/pages/index.md delete mode 100644 src/pages/index.mdx diff --git a/docs/advanced/_category_.json b/docs/advanced/_category_.json index 0d103c926..2161114e5 100644 --- a/docs/advanced/_category_.json +++ b/docs/advanced/_category_.json @@ -1,4 +1,4 @@ { - "label": "Advanced Topics", - "position": 12 + "label": "Advanced Topics", + "position": 12 } \ No newline at end of file diff --git a/docs/advanced/accesstransformers.md b/docs/advanced/accesstransformers.md index 004952069..f7399e76b 100644 --- a/docs/advanced/accesstransformers.md +++ b/docs/advanced/accesstransformers.md @@ -14,9 +14,9 @@ Access Transformers need to be declared in `build.gradle`. AT files can be speci // In build.gradle: // This block is where your mappings version is also specified minecraft { - accessTransformers { - file('src/main/resources/META-INF/accesstransformer.cfg') - } + accessTransformers { + file('src/main/resources/META-INF/accesstransformer.cfg') + } } ``` @@ -35,10 +35,10 @@ Additionally, multiple AT files can be specified and will be applied in order. T ```groovy // In build.gradle: minecraft { - accessTransformers { - file('src/main/resources/accesstransformer_main.cfg') - file('src/additions/resources/accesstransformer_additions.cfg') - } + accessTransformers { + file('src/main/resources/accesstransformer_main.cfg') + file('src/additions/resources/accesstransformer_additions.cfg') + } } ``` diff --git a/docs/advanced/extensibleenums.md b/docs/advanced/extensibleenums.md index e5737c38a..2df255c67 100644 --- a/docs/advanced/extensibleenums.md +++ b/docs/advanced/extensibleenums.md @@ -88,9 +88,9 @@ The parameters can be specified in three ways with limitations depending on the - Inline in the JSON file as an array of constants (only allowed for primitive values, Strings and for passing null to any reference type) - As a reference to a field of type `EnumProxy` in a class from the mod (see `EnumProxy` example above) - - The first parameter specifies the target enum and the subsequent parameters are the ones to be passed to the enum constructor + - The first parameter specifies the target enum and the subsequent parameters are the ones to be passed to the enum constructor - As a reference to a method returning `Object`, where the return value is the parameter value to use. The method must have exactly two parameters of type `int` (index of the parameter) and `Class` (expected type of the parameter) - - The `Class` object should be used to cast (`Class#cast()`) the return value in order to keep `ClassCastException`s in mod code. + - The `Class` object should be used to cast (`Class#cast()`) the return value in order to keep `ClassCastException`s in mod code. :::warning The fields and/or methods used as sources for parameter values should be in a separate class to avoid unintentionally loading mod classes too early. @@ -117,7 +117,7 @@ Further action is required depending on specific details about the enum: - If the enum has an int ID parameter which should match the entry's ordinal, then the enum should be annotated with `@NumberedEnum` with the ID's parameter index as the annotation's value if it's not the first parameter - If the enum has a String name parameter which is used for serialization and should therefore be namespaced, then the enum should be annotated with `@NamedEnum` with the name's parameter index as the annotation's value if it's not the first parameter - If the enum is sent over the network, then it should be annotated with `@NetworkedEnum` with the annotation's parameter specifying in which direction the values may be sent (clientbound, serverbound or bidirectional) - - Warning: networked enums will require additional steps once network checks for enums are implemented in NeoForge + - Warning: networked enums will require additional steps once network checks for enums are implemented in NeoForge - If the enum has constructors which are not usable by mods (i.e. because they require registry objects on an enum that may be initialized before modded registration runs), then they should be annotated with `@ReservedConstructor` :::note diff --git a/docs/blockentities/_category_.json b/docs/blockentities/_category_.json index 6aaa487b0..3b6467c06 100644 --- a/docs/blockentities/_category_.json +++ b/docs/blockentities/_category_.json @@ -1,4 +1,4 @@ { - "label": "Block Entities", - "position": 6 + "label": "Block Entities", + "position": 6 } \ No newline at end of file diff --git a/docs/blockentities/container.md b/docs/blockentities/container.md index 014119d82..c8e59085b 100644 --- a/docs/blockentities/container.md +++ b/docs/blockentities/container.md @@ -306,7 +306,7 @@ When iterating over the inventory contents, it is recommended to iterate over `i [block]: ../blocks/index.md [blockentity]: index.md [component]: ../resources/client/i18n.md#components -[datacomponent]: ../items/datacomponents.mdx +[datacomponent]: ../items/datacomponents.md [item]: ../items/index.md [itemstack]: ../items/index.md#itemstacks [menu]: ../gui/menus.md diff --git a/docs/blocks/_category_.json b/docs/blocks/_category_.json index 2ba9562d4..610778fed 100644 --- a/docs/blocks/_category_.json +++ b/docs/blocks/_category_.json @@ -1,4 +1,4 @@ { - "label": "Blocks", - "position": 3 + "label": "Blocks", + "position": 3 } \ No newline at end of file diff --git a/docs/concepts/_category_.json b/docs/concepts/_category_.json index 75b53e1d3..149a5089d 100644 --- a/docs/concepts/_category_.json +++ b/docs/concepts/_category_.json @@ -1,4 +1,4 @@ { - "label": "Concepts", - "position": 2 + "label": "Concepts", + "position": 2 } \ No newline at end of file diff --git a/docs/datastorage/_category_.json b/docs/datastorage/_category_.json index ec1f1022b..a04f09557 100644 --- a/docs/datastorage/_category_.json +++ b/docs/datastorage/_category_.json @@ -1,4 +1,4 @@ { - "label": "Data Storage", - "position": 8 + "label": "Data Storage", + "position": 8 } \ No newline at end of file diff --git a/docs/datastorage/attachments.md b/docs/datastorage/attachments.md index 08be20520..8fc59c4d8 100644 --- a/docs/datastorage/attachments.md +++ b/docs/datastorage/attachments.md @@ -114,5 +114,5 @@ NeoForge.EVENT_BUS.register(PlayerEvent.Clone.class, event -> { ``` [saveddata]: ./saveddata.md -[datacomponents]: ../items/datacomponents.mdx +[datacomponents]: ../items/datacomponents.md [network]: ../networking/index.md diff --git a/docs/datastorage/nbt.md b/docs/datastorage/nbt.md index 335d73084..4532cf06f 100644 --- a/docs/datastorage/nbt.md +++ b/docs/datastorage/nbt.md @@ -101,5 +101,5 @@ NBT is used in a lot of places in Minecraft. Some of the most common examples in [blockentity]: ../blockentities/index.md [datapack]: ../resources/index.md#data -[datacomponents]: ../items/datacomponents.mdx +[datacomponents]: ../items/datacomponents.md [nbtwiki]: https://minecraft.wiki/w/NBT_format diff --git a/docs/datastorage/saveddata.md b/docs/datastorage/saveddata.md index 99e61dbc9..f747197a0 100644 --- a/docs/datastorage/saveddata.md +++ b/docs/datastorage/saveddata.md @@ -27,13 +27,13 @@ For example, if a SD was named "example" within the Nether, then a file would be ```java // In some class public ExampleSavedData create() { - return new ExampleSavedData(); + return new ExampleSavedData(); } public ExampleSavedData load(CompoundTag tag, HolderLookup.Provider lookupProvider) { - ExampleSavedData data = this.create(); - // Load saved data - return data; + ExampleSavedData data = this.create(); + // Load saved data + return data; } // In some method within the class diff --git a/docs/gettingstarted/_category_.json b/docs/gettingstarted/_category_.json index 87121b812..5ed99b17a 100644 --- a/docs/gettingstarted/_category_.json +++ b/docs/gettingstarted/_category_.json @@ -1,4 +1,4 @@ { - "label": "Getting Started", - "position": 1 + "label": "Getting Started", + "position": 1 } \ No newline at end of file diff --git a/docs/gui/_category_.json b/docs/gui/_category_.json index f78a4e958..66d6d72a3 100644 --- a/docs/gui/_category_.json +++ b/docs/gui/_category_.json @@ -1,4 +1,4 @@ { - "label": "GUIs", - "position": 9 + "label": "GUIs", + "position": 9 } \ No newline at end of file diff --git a/docs/gui/menus.md b/docs/gui/menus.md index 05ee87914..8e850afc4 100644 --- a/docs/gui/menus.md +++ b/docs/gui/menus.md @@ -18,8 +18,8 @@ public static final Supplier> MY_MENU = REGISTER.register("my_m // In MyMenu, an AbstractContainerMenu subclass public MyMenu(int containerId, Inventory playerInv) { - super(MY_MENU.get(), containerId); - // ... + super(MY_MENU.get(), containerId); + // ... } ``` @@ -39,9 +39,9 @@ public static final Supplier> MY_MENU_EXTRA = REGISTER.reg // In MyMenuExtra, an AbstractContainerMenu subclass public MyMenuExtra(int containerId, Inventory playerInv, FriendlyByteBuf extraData) { - super(MY_MENU_EXTRA.get(), containerId); - // Store extra data from buffer - // ... + super(MY_MENU_EXTRA.get(), containerId); + // Store extra data from buffer + // ... } ``` @@ -58,12 +58,12 @@ Each menu should contain two constructors: one used to initialize the menu on th ```java // Client menu constructor public MyMenu(int containerId, Inventory playerInventory) { // optional FriendlyByteBuf parameter if reading data from server - this(containerId, playerInventory, /* Any default parameters here */); + this(containerId, playerInventory, /* Any default parameters here */); } // Server menu constructor public MyMenu(int containerId, Inventory playerInventory, /* Any additional parameters here. */) { - // ... + // ... } ``` @@ -78,18 +78,18 @@ A `ContainerLevelAccess` supplies the current level and block position within an ```java // Client menu constructor public MyMenuAccess(int containerId, Inventory playerInventory) { - this(containerId, playerInventory, ContainerLevelAccess.NULL); + this(containerId, playerInventory, ContainerLevelAccess.NULL); } // Server menu constructor public MyMenuAccess(int containerId, Inventory playerInventory, ContainerLevelAccess access) { - // ... + // ... } // Assume this menu is attached to Supplier MY_BLOCK @Override public boolean stillValid(Player player) { - return AbstractContainerMenu.stillValid(this.access, player, MY_BLOCK.get()); + return AbstractContainerMenu.stillValid(this.access, player, MY_BLOCK.get()); } ``` @@ -123,22 +123,22 @@ NeoForge patches the packet to provide the full integer to the client. // Client menu constructor public MyMenuAccess(int containerId, Inventory playerInventory) { - this(containerId, playerInventory, new ItemStackHandler(5), DataSlot.standalone()); + this(containerId, playerInventory, new ItemStackHandler(5), DataSlot.standalone()); } // Server menu constructor public MyMenuAccess(int containerId, Inventory playerInventory, IItemHandler dataInventory, DataSlot dataSingle) { - // Check if the data inventory size is some fixed value - // Then, add slots for data inventory - this.addSlot(new SlotItemHandler(dataInventory, /*...*/)); + // Check if the data inventory size is some fixed value + // Then, add slots for data inventory + this.addSlot(new SlotItemHandler(dataInventory, /*...*/)); - // Add slots for player inventory - this.addSlot(new Slot(playerInventory, /*...*/)); + // Add slots for player inventory + this.addSlot(new Slot(playerInventory, /*...*/)); - // Add data slots for handled integers - this.addDataSlot(dataSingle); + // Add data slots for handled integers + this.addDataSlot(dataSingle); - // ... + // ... } ``` @@ -151,18 +151,18 @@ If multiple integers need to be synced to the client, a `ContainerData` can be u // Client menu constructor public MyMenuAccess(int containerId, Inventory playerInventory) { - this(containerId, playerInventory, new SimpleContainerData(3)); + this(containerId, playerInventory, new SimpleContainerData(3)); } // Server menu constructor public MyMenuAccess(int containerId, Inventory playerInventory, ContainerData dataMultiple) { - // Check if the ContainerData size is some fixed value - checkContainerDataCount(dataMultiple, 3); + // Check if the ContainerData size is some fixed value + checkContainerDataCount(dataMultiple, 3); - // Add data slots for handled integers - this.addDataSlots(dataMultiple); + // Add data slots for handled integers + this.addDataSlots(dataMultiple); - // ... + // ... } ``` @@ -184,81 +184,81 @@ Across Minecraft implementations, this method is fairly consistent in its logic: // - Player Hotbar (32 - 40) @Override public ItemStack quickMoveStack(Player player, int quickMovedSlotIndex) { - // The quick moved slot stack - ItemStack quickMovedStack = ItemStack.EMPTY; - // The quick moved slot - Slot quickMovedSlot = this.slots.get(quickMovedSlotIndex) + // The quick moved slot stack + ItemStack quickMovedStack = ItemStack.EMPTY; + // The quick moved slot + Slot quickMovedSlot = this.slots.get(quickMovedSlotIndex) - // If the slot is in the valid range and the slot is not empty - if (quickMovedSlot != null && quickMovedSlot.hasItem()) { - // Get the raw stack to move - ItemStack rawStack = quickMovedSlot.getItem(); - // Set the slot stack to a copy of the raw stack - quickMovedStack = rawStack.copy(); - - /* - The following quick move logic can be simplified to if in data inventory, - try to move to player inventory/hotbar and vice versa for containers - that cannot transform data (e.g. chests). - */ - - // If the quick move was performed on the data inventory result slot - if (quickMovedSlotIndex == 0) { - // Try to move the result slot into the player inventory/hotbar - if (!this.moveItemStackTo(rawStack, 5, 41, true)) { - // If cannot move, no longer quick move - return ItemStack.EMPTY; - } - - // Perform logic on result slot quick move - slot.onQuickCraft(rawStack, quickMovedStack); - } - // Else if the quick move was performed on the player inventory or hotbar slot - else if (quickMovedSlotIndex >= 5 && quickMovedSlotIndex < 41) { - // Try to move the inventory/hotbar slot into the data inventory input slots - if (!this.moveItemStackTo(rawStack, 1, 5, false)) { - // If cannot move and in player inventory slot, try to move to hotbar - if (quickMovedSlotIndex < 32) { - if (!this.moveItemStackTo(rawStack, 32, 41, false)) { + // If the slot is in the valid range and the slot is not empty + if (quickMovedSlot != null && quickMovedSlot.hasItem()) { + // Get the raw stack to move + ItemStack rawStack = quickMovedSlot.getItem(); + // Set the slot stack to a copy of the raw stack + quickMovedStack = rawStack.copy(); + + /* + The following quick move logic can be simplified to if in data inventory, + try to move to player inventory/hotbar and vice versa for containers + that cannot transform data (e.g. chests). + */ + + // If the quick move was performed on the data inventory result slot + if (quickMovedSlotIndex == 0) { + // Try to move the result slot into the player inventory/hotbar + if (!this.moveItemStackTo(rawStack, 5, 41, true)) { + // If cannot move, no longer quick move + return ItemStack.EMPTY; + } + + // Perform logic on result slot quick move + slot.onQuickCraft(rawStack, quickMovedStack); + } + // Else if the quick move was performed on the player inventory or hotbar slot + else if (quickMovedSlotIndex >= 5 && quickMovedSlotIndex < 41) { + // Try to move the inventory/hotbar slot into the data inventory input slots + if (!this.moveItemStackTo(rawStack, 1, 5, false)) { + // If cannot move and in player inventory slot, try to move to hotbar + if (quickMovedSlotIndex < 32) { + if (!this.moveItemStackTo(rawStack, 32, 41, false)) { + // If cannot move, no longer quick move + return ItemStack.EMPTY; + } + } + // Else try to move hotbar into player inventory slot + else if (!this.moveItemStackTo(rawStack, 5, 32, false)) { + // If cannot move, no longer quick move + return ItemStack.EMPTY; + } + } + } + // Else if the quick move was performed on the data inventory input slots, try to move to player inventory/hotbar + else if (!this.moveItemStackTo(rawStack, 5, 41, false)) { // If cannot move, no longer quick move return ItemStack.EMPTY; - } } - // Else try to move hotbar into player inventory slot - else if (!this.moveItemStackTo(rawStack, 5, 32, false)) { - // If cannot move, no longer quick move - return ItemStack.EMPTY; - } - } - } - // Else if the quick move was performed on the data inventory input slots, try to move to player inventory/hotbar - else if (!this.moveItemStackTo(rawStack, 5, 41, false)) { - // If cannot move, no longer quick move - return ItemStack.EMPTY; - } - if (rawStack.isEmpty()) { - // If the raw stack has completely moved out of the slot, set the slot to the empty stack - quickMovedSlot.set(ItemStack.EMPTY); - } else { - // Otherwise, notify the slot that that the stack count has changed - quickMovedSlot.setChanged(); - } + if (rawStack.isEmpty()) { + // If the raw stack has completely moved out of the slot, set the slot to the empty stack + quickMovedSlot.set(ItemStack.EMPTY); + } else { + // Otherwise, notify the slot that that the stack count has changed + quickMovedSlot.setChanged(); + } - /* - The following if statement and Slot#onTake call can be removed if the - menu does not represent a container that can transform stacks (e.g. - chests). - */ - if (rawStack.getCount() == quickMovedStack.getCount()) { - // If the raw stack was not able to be moved to another slot, no longer quick move - return ItemStack.EMPTY; + /* + The following if statement and Slot#onTake call can be removed if the + menu does not represent a container that can transform stacks (e.g. + chests). + */ + if (rawStack.getCount() == quickMovedStack.getCount()) { + // If the raw stack was not able to be moved to another slot, no longer quick move + return ItemStack.EMPTY; + } + // Execute logic on what to do post move with the remaining stack + quickMovedSlot.onTake(player, rawStack); } - // Execute logic on what to do post move with the remaining stack - quickMovedSlot.onTake(player, rawStack); - } - return quickMovedStack; // Return the slot stack + return quickMovedStack; // Return the slot stack } ``` @@ -280,8 +280,8 @@ A `MenuProvider` can easily be created using `SimpleMenuProvider`, which takes i // In some implementation with access to the Player on the logical server (e.g. ServerPlayer instance) // Assume we have ServerPlayer serverPlayer serverPlayer.openMenu(new SimpleMenuProvider( - (containerId, playerInventory, player) -> new MyMenu(containerId, playerInventory), - Component.translatable("menu.title.examplemod.mymenu") + (containerId, playerInventory, player) -> new MyMenu(containerId, playerInventory), + Component.translatable("menu.title.examplemod.mymenu") )); ``` @@ -299,15 +299,15 @@ The `MenuProvider` should be implemented by overriding `BlockBehaviour#getMenuPr // In some Block subclass @Override public MenuProvider getMenuProvider(BlockState state, Level level, BlockPos pos) { - return new SimpleMenuProvider(/* ... */); + return new SimpleMenuProvider(/* ... */); } @Override public InteractionResult useWithoutItem(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult result) { - if (!level.isClientSide && player instanceof ServerPlayer serverPlayer) { - serverPlayer.openMenu(state.getMenuProvider(level, pos)); - } - return InteractionResult.sidedSuccess(level.isClientSide); + if (!level.isClientSide && player instanceof ServerPlayer serverPlayer) { + serverPlayer.openMenu(state.getMenuProvider(level, pos)); + } + return InteractionResult.sidedSuccess(level.isClientSide); } ``` @@ -321,15 +321,15 @@ Mobs typically implement a menu by overriding `Mob#mobInteract`. This is done si ```java public class MyMob extends Mob implements MenuProvider { - // ... + // ... - @Override - public InteractionResult mobInteract(Player player, InteractionHand hand) { - if (!this.level.isClientSide && player instanceof ServerPlayer serverPlayer) { - serverPlayer.openMenu(this); + @Override + public InteractionResult mobInteract(Player player, InteractionHand hand) { + if (!this.level.isClientSide && player instanceof ServerPlayer serverPlayer) { + serverPlayer.openMenu(this); + } + return InteractionResult.sidedSuccess(this.level.isClientSide); } - return InteractionResult.sidedSuccess(this.level.isClientSide); - } } ``` diff --git a/docs/items/_category_.json b/docs/items/_category_.json index 066fa0950..ce4517768 100644 --- a/docs/items/_category_.json +++ b/docs/items/_category_.json @@ -1,4 +1,4 @@ { - "label": "Items", - "position": 4 + "label": "Items", + "position": 4 } \ No newline at end of file diff --git a/docs/items/datacomponents.mdx b/docs/items/datacomponents.md similarity index 100% rename from docs/items/datacomponents.mdx rename to docs/items/datacomponents.md diff --git a/docs/items/index.md b/docs/items/index.md index c0fa0ab51..eea65dd33 100644 --- a/docs/items/index.md +++ b/docs/items/index.md @@ -7,11 +7,11 @@ Along with blocks, items are a key component of Minecraft. While blocks make up Before we get further into creating items, it is important to understand what an item actually is, and what distinguishes it from, say, a [block][block]. Let's illustrate this using an example: - In the world, you encounter a dirt block and want to mine it. This is a **block**, because it is placed in the world. (Actually, it is not a block, but a blockstate. See the [Blockstates article][blockstates] for more detailed information.) - - Not all blocks drop themselves when breaking (e.g. leaves), see the article on [loot tables][loottables] for more information. + - Not all blocks drop themselves when breaking (e.g. leaves), see the article on [loot tables][loottables] for more information. - Once you have [mined the block][breaking], it is removed (= replaced with an air block) and the dirt drops. The dropped dirt is an item **entity**. This means that like other entities (pigs, zombies, arrows, etc.), it can inherently be moved by things like water pushing on it, or burned by fire and lava. - Once you pick up the dirt item entity, it becomes an **item stack** in your inventory. An item stack is, simply put, an instance of an item with some extra information, such as the stack size. - Item stacks are backed by their corresponding **item** (which is what we're creating). Items hold [data components][datacomponents] that contains the default information all items stacks are initialized to (for example, every iron sword has a max durability of 250), while item stacks can modify those data components, allowing two different stacks for the same item to have different information (for example, one iron sword has 100 uses left, while another iron sword has 200 uses left). For more information on what is done through items and what is done through item stacks, read on. - - The relationship between items and item stacks is roughly the same as between [blocks][block] and [blockstates][blockstates], in that a blockstate is always backed by a block. It's not a really accurate comparison (item stacks aren't singletons, for example), but it gives a good basic idea about what the concept is here. + - The relationship between items and item stacks is roughly the same as between [blocks][block] and [blockstates][blockstates], in that a blockstate is always backed by a block. It's not a really accurate comparison (item stacks aren't singletons, for example), but it gives a good basic idea about what the concept is here. ## Creating an Item @@ -62,9 +62,9 @@ All registries use `DeferredRegister` to register their contents, and items are public static final DeferredRegister.Items ITEMS = DeferredRegister.createItems(ExampleMod.MOD_ID); public static final Supplier EXAMPLE_ITEM = ITEMS.registerItem( - "example_item", - Item::new, // The factory that the properties will be passed into. - new Item.Properties() // The properties to use. + "example_item", + Item::new, // The factory that the properties will be passed into. + new Item.Properties() // The properties to use. ); ``` @@ -74,8 +74,8 @@ If you want to use `Item::new`, you can leave out the factory entirely and use t ```java public static final Supplier EXAMPLE_ITEM = ITEMS.registerSimpleItem( - "example_item", - new Item.Properties() // The properties to use. + "example_item", + new Item.Properties() // The properties to use. ); ``` @@ -92,13 +92,24 @@ public static final Supplier EXAMPLE_ITEM = ITEMS.registerSimpleItem("exam Finally, there's also shortcuts for block items: ```java -public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem("example_block", ExampleBlocksClass.EXAMPLE_BLOCK, new Item.Properties()); +public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem( + "example_block", + ExampleBlocksClass.EXAMPLE_BLOCK, new Item.Properties() +); // Variant that omits the properties parameter: -public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem("example_block", ExampleBlocksClass.EXAMPLE_BLOCK); +public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem( + "example_block", + ExampleBlocksClass.EXAMPLE_BLOCK +); // Variant that omits the name parameter, instead using the block's registry name: -public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem(ExampleBlocksClass.EXAMPLE_BLOCK, new Item.Properties()); +public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem( + ExampleBlocksClass.EXAMPLE_BLOCK, + new Item.Properties() +); // Variant that omits both the name and the properties: -public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem(ExampleBlocksClass.EXAMPLE_BLOCK); +public static final Supplier EXAMPLE_BLOCK_ITEM = ITEMS.registerSimpleBlockItem( + ExampleBlocksClass.EXAMPLE_BLOCK +); ``` :::note @@ -143,14 +154,14 @@ In many situations, for example [recipes], item stacks need to be represented as ```json5 { - // The item ID. Required. - "id": "minecraft:dirt", - // The item stack count. Optional, defaults to 1. - "count": 4, - // A map of data components. Optional, defaults to an empty map. - "components": { - "minecraft:enchantment_glint_override": true - } + // The item ID. Required. + "id": "minecraft:dirt", + // The item stack count. Optional, defaults to 1. + "count": 4, + // A map of data components. Optional, defaults to an empty map. + "components": { + "minecraft:enchantment_glint_override": true + } } ``` @@ -214,7 +225,7 @@ It is also possible to implement `ItemLike` on your custom objects. Simply overr [blockstates]: ../blocks/states.md [breaking]: ../blocks/index.md#breaking-a-block [creativetabs]: #creative-tabs -[datacomponents]: ./datacomponents.mdx +[datacomponents]: ./datacomponents.md [datagen]: ../resources/index.md#data-generation [food]: #food [hunger]: https://minecraft.wiki/w/Hunger#Mechanics diff --git a/docs/items/mobeffects.md b/docs/items/mobeffects.md index 87cf3cf69..2b68ae4ce 100644 --- a/docs/items/mobeffects.md +++ b/docs/items/mobeffects.md @@ -8,7 +8,7 @@ Status effects, sometimes known as potion effects and referred to in-code as `Mo ## Terminology - A `MobEffect` affects an entity every tick. Like [blocks][block] or [items][item], `MobEffect`s are registry objects, meaning they must be [registered][registration] and are singletons. - - An **instant mob effect** is a special kind of mob effect that is designed to be applied for one tick. Vanilla has two instant effects, Instant Health and Instant Harming. + - An **instant mob effect** is a special kind of mob effect that is designed to be applied for one tick. Vanilla has two instant effects, Instant Health and Instant Harming. - A `MobEffectInstance` is an instance of a `MobEffect`, with a duration, amplifier and some other properties set (see below). `MobEffectInstance`s are to `MobEffect`s what [`ItemStack`s][itemstack] are to `Item`s. - A `Potion` is a collection of `MobEffectInstance`s. Vanilla mainly uses potions for the four potion items (read on), however, they can be applied to any item at will. It is up to the item if and how the item then uses the potion set on it. - A **potion item** is an item that is meant to have a potion set on it. This is an informal term, the vanilla `PotionItem` class has nothing to do with this (it refers to the "normal" potion item). Minecraft currently has four potion items: potions, splash potions, lingering potions, and tipped arrows; however more may be added by mods. diff --git a/docs/items/tools.md b/docs/items/tools.md index 97cef82f0..03637c91d 100644 --- a/docs/items/tools.md +++ b/docs/items/tools.md @@ -12,12 +12,12 @@ A tool set typically consists of five items: a pickaxe, an axe, a shovel, a hoe ```text Item - TieredItem - - DiggerItem - - AxeItem - - HoeItem - - PickaxeItem - - ShovelItem - - SwordItem + - DiggerItem + - AxeItem + - HoeItem + - PickaxeItem + - ShovelItem + - SwordItem ``` `TieredItem` is a class that contains helpers for items with a certain `Tier` (read on). `DiggerItem` contains helpers for items that are designed to break blocks. Note that other items usually considered tools, such as shears, are not included in this hierarchy. Instead, they directly extend `Item` and hold the breaking logic themselves. @@ -93,14 +93,14 @@ And then, we populate our tag. For example, let's make copper able to mine gold ```json5 { - "values": [ - "minecraft:gold_block", - "minecraft:raw_gold_block", - "minecraft:gold_ore", - "minecraft:deepslate_gold_ore", - "minecraft:redstone_ore", - "minecraft:deepslate_redstone_ore" - ] + "values": [ + "minecraft:gold_block", + "minecraft:raw_gold_block", + "minecraft:gold_ore", + "minecraft:deepslate_gold_ore", + "minecraft:redstone_ore", + "minecraft:deepslate_redstone_ore" + ] } ``` @@ -233,7 +233,7 @@ public static final Supplier COPPER_BOOTS = ITEMS.register("copper_bo When creating your armor texture, it is a good idea to work on top of the vanilla armor texture to see which part goes where. [block]: ../blocks/index.md -[datacomponents]: ./datacomponents.mdx +[datacomponents]: ./datacomponents.md [item]: index.md [itemability]: #itemabilitys [tags]: ../resources/server/tags.md diff --git a/docs/legacy/_category_.json b/docs/legacy/_category_.json index 57032bfbb..3a78b370e 100644 --- a/docs/legacy/_category_.json +++ b/docs/legacy/_category_.json @@ -1,4 +1,4 @@ { - "label": "Legacy", - "position": 14 + "label": "Legacy", + "position": 14 } \ No newline at end of file diff --git a/docs/misc/_category_.json b/docs/misc/_category_.json index 3f9e25c78..366f98727 100644 --- a/docs/misc/_category_.json +++ b/docs/misc/_category_.json @@ -1,4 +1,4 @@ { - "label": "Miscellaneous", - "position": 13 + "label": "Miscellaneous", + "position": 13 } \ No newline at end of file diff --git a/docs/misc/gametest.mdx b/docs/misc/gametest.md similarity index 87% rename from docs/misc/gametest.mdx rename to docs/misc/gametest.md index 5bb5543f9..4702ae51f 100644 --- a/docs/misc/gametest.mdx +++ b/docs/misc/gametest.md @@ -18,10 +18,10 @@ A Game Test method is a `Consumer` reference, meaning it takes i ```java public class ExampleGameTests { - @GameTest - public static void exampleTest(GameTestHelper helper) { - // Do stuff - } + @GameTest + public static void exampleTest(GameTestHelper helper) { + // Do stuff + } } ``` @@ -30,11 +30,11 @@ The `@GameTest` annotation also contains members which configure how the game te ```java // In some class @GameTest( - setupTicks = 20L, // The test spends 20 ticks to set up for execution - required = false // The failure is logged but does not affect the execution of the batch + setupTicks = 20L, // The test spends 20 ticks to set up for execution + required = false // The failure is logged but does not affect the execution of the batch ) public static void exampleConfiguredTest(GameTestHelper helper) { - // Do stuff + // Do stuff } ``` @@ -89,10 +89,10 @@ If Game Test methods need to be generated dynamically, a test method generator c ```java public class ExampleGameTests { - @GameTestGenerator - public static Collection exampleTests() { - // Return a collection of TestFunctions - } + @GameTestGenerator + public static Collection exampleTests() { + // Return a collection of TestFunctions + } } ``` @@ -114,15 +114,15 @@ Batch methods are `Consumer` references, meaning they take in a `Se ```java public class ExampleGameTests { - @BeforeBatch(batch = "firstBatch") - public static void beforeTest(ServerLevel level) { - // Perform setup - } - - @GameTest(batch = "firstBatch") - public static void exampleTest2(GameTestHelper helper) { - // Do stuff - } + @BeforeBatch(batch = "firstBatch") + public static void beforeTest(ServerLevel level) { + // Perform setup + } + + @GameTest(batch = "firstBatch") + public static void exampleTest2(GameTestHelper helper) { + // Do stuff + } } ``` @@ -137,7 +137,7 @@ The `@GameTestHolder` annotation registers any test methods within the type (cla ```java @GameTestHolder(MODID) public class ExampleGameTests { - // ... + // ... } ``` @@ -148,13 +148,13 @@ public class ExampleGameTests { ```java // In some class public void registerTests(RegisterGameTestsEvent event) { - event.register(ExampleGameTests.class); + event.register(ExampleGameTests.class); } // In ExampleGameTests @GameTest(templateNamespace = MODID) public static void exampleTest3(GameTestHelper helper) { - // Perform setup + // Perform setup } ``` @@ -187,27 +187,27 @@ The name of the template is determined by `GameTest#template`. If not specified, @GameTestHolder(MODID) public class ExampleGameTests { - // Class name is prepended, template name is not specified - // Template Location at 'modid:examplegametests.exampletest' - @GameTest - public static void exampleTest(GameTestHelper helper) { /*...*/ } - - // Class name is not prepended, template name is not specified - // Template Location at 'modid:exampletest2' - @PrefixGameTestTemplate(false) - @GameTest - public static void exampleTest2(GameTestHelper helper) { /*...*/ } - - // Class name is prepended, template name is specified - // Template Location at 'modid:examplegametests.test_template' - @GameTest(template = "test_template") - public static void exampleTest3(GameTestHelper helper) { /*...*/ } - - // Class name is not prepended, template name is specified - // Template Location at 'modid:test_template2' - @PrefixGameTestTemplate(false) - @GameTest(template = "test_template2") - public static void exampleTest4(GameTestHelper helper) { /*...*/ } + // Class name is prepended, template name is not specified + // Template Location at 'modid:examplegametests.exampletest' + @GameTest + public static void exampleTest(GameTestHelper helper) { /*...*/ } + + // Class name is not prepended, template name is not specified + // Template Location at 'modid:exampletest2' + @PrefixGameTestTemplate(false) + @GameTest + public static void exampleTest2(GameTestHelper helper) { /*...*/ } + + // Class name is prepended, template name is specified + // Template Location at 'modid:examplegametests.test_template' + @GameTest(template = "test_template") + public static void exampleTest3(GameTestHelper helper) { /*...*/ } + + // Class name is not prepended, template name is specified + // Template Location at 'modid:test_template2' + @PrefixGameTestTemplate(false) + @GameTest(template = "test_template2") + public static void exampleTest4(GameTestHelper helper) { /*...*/ } } ``` @@ -249,7 +249,7 @@ There must be no spaces in-between namespaces; otherwise, the namespace will not The Game Test Server is a special configuration which runs a build server. The build server returns an exit code of the number of required, failed Game Tests. All failed tests, whether required or optional, are logged. This server can be run using `gradlew runGameTestServer`.
- Important infromation on NeoGradle +Important infromation on NeoGradle :::caution Due to a quirk in how Gradle works, by default, if a task forces a system exit, the Gradle daemon will be killed, causing the Gradle runner to report a build failure. NeoGradle sets by default a force exit on run tasks such that any subprojects are not executed in sequence. However, as such, the Game Test Server will always fail. diff --git a/docs/misc/keymappings.md b/docs/misc/keymappings.md index 2337d3343..d84dab4d9 100644 --- a/docs/misc/keymappings.md +++ b/docs/misc/keymappings.md @@ -15,7 +15,7 @@ public static final Lazy EXAMPLE_MAPPING = Lazy.of(() -> /*...*/); // Event is on the mod event bus only on the physical client @SubscribeEvent public void registerBindings(RegisterKeyMappingsEvent event) { - event.register(EXAMPLE_MAPPING.get()); + event.register(EXAMPLE_MAPPING.get()); } ``` @@ -41,10 +41,10 @@ The integer is dependent on the type provided. All input codes are defined in `G ```java new KeyMapping( - "key.examplemod.example1", // Will be localized using this translation key - InputConstants.Type.KEYSYM, // Default mapping is on the keyboard - GLFW.GLFW_KEY_P, // Default key is P - "key.categories.misc" // Mapping will be in the misc category + "key.examplemod.example1", // Will be localized using this translation key + InputConstants.Type.KEYSYM, // Default mapping is on the keyboard + GLFW.GLFW_KEY_P, // Default key is P + "key.categories.misc" // Mapping will be in the misc category ) ``` @@ -62,11 +62,11 @@ Currently, NeoForge defines three basic contexts through `KeyConflictContext`: ` ```java new KeyMapping( - "key.examplemod.example2", - KeyConflictContext.GUI, // Mapping can only be used when a screen is open - InputConstants.Type.MOUSE, // Default mapping is on the mouse - GLFW.GLFW_MOUSE_BUTTON_LEFT, // Default mouse input is the left mouse button - "key.categories.examplemod.examplecategory" // Mapping will be in the new example category + "key.examplemod.example2", + KeyConflictContext.GUI, // Mapping can only be used when a screen is open + InputConstants.Type.MOUSE, // Default mapping is on the mouse + GLFW.GLFW_MOUSE_BUTTON_LEFT, // Default mouse input is the left mouse button + "key.categories.examplemod.examplecategory" // Mapping will be in the new example category ) ``` @@ -78,12 +78,12 @@ A modifier can be added in the [controls option menu][controls] by holding down ```java new KeyMapping( - "key.examplemod.example3", - KeyConflictContext.UNIVERSAL, - KeyModifier.SHIFT, // Default mapping requires shift to be held down - InputConstants.Type.KEYSYM, // Default mapping is on the keyboard - GLFW.GLFW_KEY_G, // Default key is G - "key.categories.misc" + "key.examplemod.example3", + KeyConflictContext.UNIVERSAL, + KeyModifier.SHIFT, // Default mapping requires shift to be held down + InputConstants.Type.KEYSYM, // Default mapping is on the keyboard + GLFW.GLFW_KEY_G, // Default key is G + "key.categories.misc" ) ``` @@ -118,11 +118,11 @@ Within a GUI, a mapping can be checked within one of the `GuiEventListener` meth // In some Screen subclass @Override public boolean keyPressed(int key, int scancode, int mods) { - if (EXAMPLE_MAPPING.get().isActiveAndMatches(InputConstants.getKey(key, scancode))) { - // Execute logic to perform on key press here - return true; - } - return super.keyPressed(x, y, button); + if (EXAMPLE_MAPPING.get().isActiveAndMatches(InputConstants.getKey(key, scancode))) { + // Execute logic to perform on key press here + return true; + } + return super.keyPressed(x, y, button); } ``` @@ -136,11 +136,11 @@ If you do not own the screen which you are trying to check a **key** for, you ca // In some Screen subclass @Override public boolean mouseClicked(double x, double y, int button) { - if (EXAMPLE_MAPPING.get().isActiveAndMatches(InputConstants.TYPE.MOUSE.getOrCreate(button))) { - // Execute logic to perform on mouse click here - return true; - } - return super.mouseClicked(x, y, button); + if (EXAMPLE_MAPPING.get().isActiveAndMatches(InputConstants.TYPE.MOUSE.getOrCreate(button))) { + // Execute logic to perform on mouse click here + return true; + } + return super.mouseClicked(x, y, button); } ``` diff --git a/docs/misc/updatechecker.md b/docs/misc/updatechecker.md index 0c3beefa3..79a601dba 100644 --- a/docs/misc/updatechecker.md +++ b/docs/misc/updatechecker.md @@ -12,19 +12,19 @@ The JSON itself has a relatively simple format as follows: ```json5 { - "homepage": "", - "": { - "": "", - // List all versions of your mod for the given Minecraft version, along with their changelogs - // ... - }, - "promos": { - "-latest": "", - // Declare the latest "bleeding-edge" version of your mod for the given Minecraft version - "-recommended": "", - // Declare the latest "stable" version of your mod for the given Minecraft version - // ... - } + "homepage": "", + "": { + "": "", + // List all versions of your mod for the given Minecraft version, along with their changelogs + // ... + }, + "promos": { + "-latest": "", + // Declare the latest "bleeding-edge" version of your mod for the given Minecraft version + "-recommended": "", + // Declare the latest "stable" version of your mod for the given Minecraft version + // ... + } } ``` diff --git a/docs/networking/_category_.json b/docs/networking/_category_.json index 366f94e36..31c81bdb0 100644 --- a/docs/networking/_category_.json +++ b/docs/networking/_category_.json @@ -1,4 +1,4 @@ { - "label": "Networking", - "position": 11 + "label": "Networking", + "position": 11 } \ No newline at end of file diff --git a/docs/resources/_category_.json b/docs/resources/_category_.json index db2c53c5d..5f05cd315 100644 --- a/docs/resources/_category_.json +++ b/docs/resources/_category_.json @@ -1,4 +1,4 @@ { - "label": "Resources", - "position": 7 + "label": "Resources", + "position": 7 } \ No newline at end of file diff --git a/docs/resources/client/_category_.json b/docs/resources/client/_category_.json index f785d798d..c1b8c6d90 100644 --- a/docs/resources/client/_category_.json +++ b/docs/resources/client/_category_.json @@ -1,3 +1,3 @@ { - "label": "Client" + "label": "Client" } \ No newline at end of file diff --git a/docs/resources/client/i18n.md b/docs/resources/client/i18n.md index 39e5beb51..ec06c0a49 100644 --- a/docs/resources/client/i18n.md +++ b/docs/resources/client/i18n.md @@ -103,8 +103,8 @@ A language file generally looks like this: ```json { - "translation.key.1": "Translation 1", - "translation.key.2": "Translation 2" + "translation.key.1": "Translation 1", + "translation.key.2": "Translation 2" } ``` diff --git a/docs/resources/client/models/modelloaders.md b/docs/resources/client/models/modelloaders.md index 49f5bd808..705e68304 100644 --- a/docs/resources/client/models/modelloaders.md +++ b/docs/resources/client/models/modelloaders.md @@ -68,7 +68,7 @@ The dynamic fluid container model, also called dynamic bucket model after its mo "cover_is_mask": false, // Optional, defaults to true. Whether to apply the fluid's luminosity to the item model. "apply_fluid_luminosity": false, - } +} ``` Very often, dynamic fluid container models will directly use the bucket model. This is done by specifying the `neoforge:item_bucket` parent model, like so: diff --git a/docs/resources/index.md b/docs/resources/index.md index 144dae506..a74519b6c 100644 --- a/docs/resources/index.md +++ b/docs/resources/index.md @@ -141,11 +141,11 @@ The data generator can accept several command line arguments: - `--existing path/to/folder`: Tells the data generator to consider the given folder when checking for existing files. Like with the output, it is recommended to use Gradle's `file(...).getAbsolutePath()`. - `--existing-mod examplemod`: Tells the data generator to consider the resources in the given mod's JAR file when checking for existing files. - Generator modes (all of these are boolean arguments and do not need any additional arguments): - - `--includeClient`: Whether to generate client resources (assets). Check at runtime with `GatherDataEvent#includeClient()`. - - `--includeServer`: Whether to generate server resources (data). Check at runtime with `GatherDataEvent#includeServer()`. - - `--includeDev`: Whether to run dev tools. Generally shouldn't be used by mods. Check at runtime with `GatherDataEvent#includeDev()`. - - `--includeReports`: Whether to dump a list of registered objects. Check at runtime with `GatherDataEvent#includeReports()`. - - `--all`: Enable all generator modes. + - `--includeClient`: Whether to generate client resources (assets). Check at runtime with `GatherDataEvent#includeClient()`. + - `--includeServer`: Whether to generate server resources (data). Check at runtime with `GatherDataEvent#includeServer()`. + - `--includeDev`: Whether to run dev tools. Generally shouldn't be used by mods. Check at runtime with `GatherDataEvent#includeDev()`. + - `--includeReports`: Whether to dump a list of registered objects. Check at runtime with `GatherDataEvent#includeReports()`. + - `--all`: Enable all generator modes. All arguments can be added to the run configurations by adding the following to your `build.gradle`: diff --git a/docs/resources/server/_category_.json b/docs/resources/server/_category_.json index dd4398342..8de78b39d 100644 --- a/docs/resources/server/_category_.json +++ b/docs/resources/server/_category_.json @@ -1,3 +1,3 @@ { - "label": "Server" + "label": "Server" } \ No newline at end of file diff --git a/docs/resources/server/advancements.md b/docs/resources/server/advancements.md index 191b4107e..38e6de139 100644 --- a/docs/resources/server/advancements.md +++ b/docs/resources/server/advancements.md @@ -10,21 +10,21 @@ An advancement JSON file may contain the following entries: - `parent`: The parent advancement ID of this advancement. Circular references will be detected and cause a loading failure. Optional; if absent, this advancement will be considered a root advancement. Root advancements are advancements that have no parent set. They will be the root of their [advancement tree][tree]. - `display`: The object holding several properties used for display of the advancement in the advancement GUI. Optional; if absent, this advancement will be invisible, but can still be triggered. - - `icon`: A [JSON representation of an item stack][itemstackjson]. - - `text`: A [text component][text] to use as the advancement's title. - - `description`: A [text component][text] to use as the advancement's description. - - `frame`: The frame type of the advancement. Accepts `challenge`, `goal` and `task`. Optional, defaults to `task`. - - `background`: The texture to use for the tree background. This is not relative to the `textures` directory, i.e. the `textures/` folder prefix must be included. Optional, defaults to the missing texture. Only effective on root advancements. - - `show_toast`: Whether to show a toast in the top right corner on completion. Optional, defaults to true. - - `announce_to_chat`: Whether to announce advancement completion in the chat. Optional, defaults to true. - - `hidden`: Whether to hide this advancement and all children from the advancement GUI until it is completed. Has no effect on root advancements themselves, but still hides all of their children. Optional, defaults to false. + - `icon`: A [JSON representation of an item stack][itemstackjson]. + - `text`: A [text component][text] to use as the advancement's title. + - `description`: A [text component][text] to use as the advancement's description. + - `frame`: The frame type of the advancement. Accepts `challenge`, `goal` and `task`. Optional, defaults to `task`. + - `background`: The texture to use for the tree background. This is not relative to the `textures` directory, i.e. the `textures/` folder prefix must be included. Optional, defaults to the missing texture. Only effective on root advancements. + - `show_toast`: Whether to show a toast in the top right corner on completion. Optional, defaults to true. + - `announce_to_chat`: Whether to announce advancement completion in the chat. Optional, defaults to true. + - `hidden`: Whether to hide this advancement and all children from the advancement GUI until it is completed. Has no effect on root advancements themselves, but still hides all of their children. Optional, defaults to false. - `criteria`: A map of criteria this advancement should track. Every criterion is identified by its map key. A list of criteria triggers added by Minecraft can be found in the `CriteriaTriggers` class, and the JSON specifications can be found on the [Minecraft Wiki][triggers]. For implementing your own criteria or triggering criteria from code, see below. - `requirements`: A list of lists that determine what criteria are required. This is a list of OR lists that are ANDed together, or in other words, every sublist must have at least one criterion matching. Optional, defaults to all criteria being required. - `rewards`: An object representing the rewards to grant when this advancement is completed. Optional, all values of the object are also optional. - - `experience`: The amount of experience to award to the player. - - `recipes`: A list of [recipe] IDs to unlock. - - `loot`: A list of [loot tables][loottable] to roll and give to the player. - - `function`: A [function] to run. If you want to run multiple functions, create a wrapper function that runs all other functions. + - `experience`: The amount of experience to award to the player. + - `recipes`: A list of [recipe] IDs to unlock. + - `loot`: A list of [loot tables][loottable] to roll and give to the player. + - `function`: A [function] to run. If you want to run multiple functions, create a wrapper function that runs all other functions. - `sends_telemetry_event`: Determines whether telemetry data should be collected when this advancement is completed or not. Only actually does anything if in the `minecraft` namespace. Optional, defaults to false. - `neoforge:conditions`: NeoForge-added. A list of [conditions] that must be passed for the advancement to be loaded. Optional. diff --git a/docs/resources/server/conditions.md b/docs/resources/server/conditions.md index e4673660e..139b43543 100644 --- a/docs/resources/server/conditions.md +++ b/docs/resources/server/conditions.md @@ -6,16 +6,16 @@ Most JSON files can optionally declare a `neoforge:conditions` block in the root ```json5 { - "neoforge:conditions": [ - { - // Condition 1 - }, - { - // Condition 2 - }, - // ... - ], - // The rest of the data file + "neoforge:conditions": [ + { + // Condition 1 + }, + { + // Condition 2 + }, + // ... + ], + // The rest of the data file } ``` @@ -23,16 +23,16 @@ For example, if we want to only load our file if a mod with id `examplemod` is p ```json5 { - // highlight-start - "neoforge:conditions": [ - { - "type": "neoforge:mod_loaded", - "modid": "examplemod" - } - ], - // highlight-end - "type": "minecraft:crafting_shaped", - // ... + // highlight-start + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "examplemod" + } + ], + // highlight-end + "type": "minecraft:crafting_shaped", + // ... } ``` @@ -48,8 +48,8 @@ These consist of no data and return the expected value. ```json5 { - // Will always return true (or false for "neoforge:false") - "type": "neoforge:true" + // Will always return true (or false for "neoforge:false") + "type": "neoforge:true" } ``` @@ -69,11 +69,11 @@ This condition accepts another condition and inverts it. ```json5 { - // Inverts the result of the stored condition - "type": "neoforge:not", - "value": { - // Another condition - } + // Inverts the result of the stored condition + "type": "neoforge:not", + "value": { + // Another condition + } } ``` @@ -83,16 +83,16 @@ These conditions accept the condition(s) being operated upon and apply the expec ```json5 { - // ANDs the stored conditions together (or ORs for "neoforge:or") - "type": "neoforge:and", - "values": [ - { - // First condition - }, - { - // Second condition - } - ] + // ANDs the stored conditions together (or ORs for "neoforge:or") + "type": "neoforge:and", + "values": [ + { + // First condition + }, + { + // Second condition + } + ] } ``` @@ -102,9 +102,9 @@ This condition returns true if a mod with the given mod id is loaded, and false ```json5 { - "type": "neoforge:mod_loaded", - // Returns true if "examplemod" is loaded - "modid": "examplemod" + "type": "neoforge:mod_loaded", + // Returns true if "examplemod" is loaded + "modid": "examplemod" } ``` @@ -114,9 +114,9 @@ This condition returns true if an item with the given registry name has been reg ```json5 { - "type": "neoforge:item_exists", - // Returns true if "examplemod:example_item" has been registered - "item": "examplemod:example_item" + "type": "neoforge:item_exists", + // Returns true if "examplemod:example_item" has been registered + "item": "examplemod:example_item" } ``` @@ -126,9 +126,9 @@ This condition returns true if the given item [tag] is empty, and false otherwis ```json5 { - "type": "neoforge:tag_empty", - // Returns true if "examplemod:example_tag" is an empty item tag - "tag": "examplemod:example_tag" + "type": "neoforge:tag_empty", + // Returns true if "examplemod:example_tag" is an empty item tag + "tag": "examplemod:example_tag" } ``` @@ -171,13 +171,13 @@ And then, we can use our condition in some data file (assuming we registered the ```json5 { - "neoforge:conditions": [ - { - "type": "examplemod:entity_tag_empty", - "tag": "minecraft:zombies" - } - ], - // The rest of the data file + "neoforge:conditions": [ + { + "type": "examplemod:entity_tag_empty", + "tag": "minecraft:zombies" + } + ], + // The rest of the data file } ``` diff --git a/docs/resources/server/damagetypes.md b/docs/resources/server/damagetypes.md index af40c2e25..28bef4629 100644 --- a/docs/resources/server/damagetypes.md +++ b/docs/resources/server/damagetypes.md @@ -17,23 +17,23 @@ Now that we can reference it from code, let's specify some properties in the dat ```json5 { - // The death message id of the damage type. The full death message translation key will be - // "death.examplemod.example" (with swapped-out mod ids and names). - "message_id": "example", - // Whether this damage type's damage amount scales with difficulty or not. Valid vanilla values are: - // - "never": The damage value remains the same on any difficulty. Common for player-caused damage types. - // - "when_caused_by_living_non_player": The damage value is scaled if the entity is caused by a - // living entity of some sort, including indirectly (e.g. an arrow shot by a skeleton), that is not a player. - // - "always": The damage value is always scaled. Commonly used by explosion-like damage. - "scaling": "when_caused_by_living_non_player", - // The amount of exhaustion caused by receiving this kind of damage. - "exhaustion": 0.1, - // The damage effects (currently only sound effects) that are applied when receiving this kind of damage. Optional. - // Valid vanilla values are "hurt" (default), "thorns", "drowning", "burning", "poking", and "freezing". - "effects": "hurt", - // The death message type. Determines how the death message is built. Optional. - // Valid vanilla values are "default" (default), "fall_variants", and "intentional_game_design". - "death_message_type": "default" + // The death message id of the damage type. The full death message translation key will be + // "death.examplemod.example" (with swapped-out mod ids and names). + "message_id": "example", + // Whether this damage type's damage amount scales with difficulty or not. Valid vanilla values are: + // - "never": The damage value remains the same on any difficulty. Common for player-caused damage types. + // - "when_caused_by_living_non_player": The damage value is scaled if the entity is caused by a + // living entity of some sort, including indirectly (e.g. an arrow shot by a skeleton), that is not a player. + // - "always": The damage value is always scaled. Commonly used by explosion-like damage. + "scaling": "when_caused_by_living_non_player", + // The amount of exhaustion caused by receiving this kind of damage. + "exhaustion": 0.1, + // The damage effects (currently only sound effects) that are applied when receiving this kind of damage. Optional. + // Valid vanilla values are "hurt" (default), "thorns", "drowning", "burning", "poking", and "freezing". + "effects": "hurt", + // The death message type. Determines how the death message is built. Optional. + // Valid vanilla values are "default" (default), "fall_variants", and "intentional_game_design". + "death_message_type": "default" } ``` diff --git a/docs/resources/server/datamaps/builtin.md b/docs/resources/server/datamaps/builtin.md index 87d1e24bc..8ae8b90df 100644 --- a/docs/resources/server/datamaps/builtin.md +++ b/docs/resources/server/datamaps/builtin.md @@ -8,10 +8,10 @@ Allows configuring composter values, as a replacement for `ComposterBlock.COMPOS ```json5 { - // A 0 to 1 (inclusive) float representing the chance that the item will update the level of the composter - "chance": 1, - // Optional, defaults to false - whether farmer villagers can compost this item - "can_villager_compost": false + // A 0 to 1 (inclusive) float representing the chance that the item will update the level of the composter + "chance": 1, + // Optional, defaults to false - whether farmer villagers can compost this item + "can_villager_compost": false } ``` @@ -19,12 +19,12 @@ Example: ```json5 { - "values": { - // Give acacia logs a 50% chance that they will fill a composter - "minecraft:acacia_log": { - "chance": 0.5 + "values": { + // Give acacia logs a 50% chance that they will fill a composter + "minecraft:acacia_log": { + "chance": 0.5 + } } - } } ``` @@ -34,8 +34,8 @@ Allows configuring item burn times. This data map is located at `neoforge/data_m ```json5 { - // A positive integer representing the item's burn time in ticks - "burn_time": 1000 + // A positive integer representing the item's burn time in ticks + "burn_time": 1000 } ``` @@ -43,12 +43,12 @@ Example: ```json5 { - "values": { - // Give anvils a 2 seconds burn time - "minecraft:anvil": { - "burn_time": 40 + "values": { + // Give anvils a 2 seconds burn time + "minecraft:anvil": { + "burn_time": 40 + } } - } } ``` @@ -61,17 +61,17 @@ Vanilla adds an implicit burn time of 300 ticks (15 seconds) for `#minecraft:log ```json5 { - "replace": false, - "values": [ - // values here - ], - "remove": [ - "examplemod:example_nether_wood_planks", - "#examplemod:example_nether_wood_stems", - "examplemod:example_nether_wood_door", - // etc. - // other removals here - ] + "replace": false, + "values": [ + // values here + ], + "remove": [ + "examplemod:example_nether_wood_planks", + "#examplemod:example_nether_wood_stems", + "examplemod:example_nether_wood_door", + // etc. + // other removals here + ] } ``` ::: @@ -82,8 +82,8 @@ Allows configuring the mobs that may appear in the mob spawner in a monster room ```json5 { - // The weight of this mob, relative to other mobs in the datamap - "weight": 100 + // The weight of this mob, relative to other mobs in the datamap + "weight": 100 } ``` @@ -91,12 +91,12 @@ Example: ```json5 { - "values": { - // Make squids appear in monster room spawners with a weight of 100 - "minecraft:squid": { - "weight": 100 + "values": { + // Make squids appear in monster room spawners with a weight of 100 + "minecraft:squid": { + "weight": 100 + } } - } } ``` @@ -106,8 +106,8 @@ Allows configuring oxidation stages, as a replacement for `WeatheringCopper#NEXT ```json5 { - // The block this block will turn into once oxidized - "next_oxidized_stage": "examplemod:oxidized_block" + // The block this block will turn into once oxidized + "next_oxidized_stage": "examplemod:oxidized_block" } ``` @@ -119,12 +119,12 @@ Example: ```json5 { - "values": { - "mymod:custom_copper": { - // Make a custom copper block oxidize into custom oxidized copper - "next_oxidized_stage": "mymod:custom_oxidized_copper" + "values": { + "mymod:custom_copper": { + // Make a custom copper block oxidize into custom oxidized copper + "next_oxidized_stage": "mymod:custom_oxidized_copper" + } } - } } ``` @@ -134,8 +134,8 @@ Allows configuring the sounds produced by parrots when they want to imitate a mo ```json5 { - // The ID of the sound that parrots will produce when imitating the mob - "sound": "minecraft:entity.parrot.imitate.creeper" + // The ID of the sound that parrots will produce when imitating the mob + "sound": "minecraft:entity.parrot.imitate.creeper" } ``` @@ -143,12 +143,12 @@ Example: ```json5 { - "values": { - // Make parrots produce the ambient cave sound when imitating allays - "minecraft:allay": { - "sound": "minecraft:ambient.cave" + "values": { + // Make parrots produce the ambient cave sound when imitating allays + "minecraft:allay": { + "sound": "minecraft:ambient.cave" + } } - } } ``` @@ -158,8 +158,8 @@ Allows configuring the gift that a villager with a certain `VillagerProfession` ```json5 { - // The ID of the loot table that a villager profession will hand out after a raid - "loot_table": "minecraft:gameplay/hero_of_the_village/armorer_gift" + // The ID of the loot table that a villager profession will hand out after a raid + "loot_table": "minecraft:gameplay/hero_of_the_village/armorer_gift" } ``` @@ -167,12 +167,12 @@ Example: ```json5 { - "values": { - "minecraft:armorer": { - // Make armorers give the raid hero the armorer gift loot table - "loot_table": "minecraft:gameplay/hero_of_the_village/armorer_gift" + "values": { + "minecraft:armorer": { + // Make armorers give the raid hero the armorer gift loot table + "loot_table": "minecraft:gameplay/hero_of_the_village/armorer_gift" + } } - } } ``` @@ -182,8 +182,8 @@ Allows configuring the sculk vibration frequencies emitted by game events, as a ```json5 { - // An integer between 1 and 15 (inclusive) that indicates the vibration frequency of the event - "frequency": 2 + // An integer between 1 and 15 (inclusive) that indicates the vibration frequency of the event + "frequency": 2 } ``` @@ -191,12 +191,12 @@ Example: ```json5 { - "values": { - // Make the splash in water game event vibrate on the second frequency - "minecraft:splash": { - "frequency": 2 + "values": { + // Make the splash in water game event vibrate on the second frequency + "minecraft:splash": { + "frequency": 2 + } } - } } ``` @@ -206,8 +206,8 @@ Allows configuring the block a block will turn into when waxed (right clicked wi ```json5 { - // The waxed variant of this block - "waxed": "minecraft:iron_block" + // The waxed variant of this block + "waxed": "minecraft:iron_block" } ``` @@ -215,14 +215,14 @@ Example: ```json5 { - "values": { - // Make gold blocks turn into iron blocks once waxed - "minecraft:gold_block": { - "waxed": "minecraft:iron_block" + "values": { + // Make gold blocks turn into iron blocks once waxed + "minecraft:gold_block": { + "waxed": "minecraft:iron_block" + } } - } } ``` -[datacomponent]: ../../../items/datacomponents.mdx +[datacomponent]: ../../../items/datacomponents.md [datamap]: index.md diff --git a/docs/resources/server/datamaps/index.md b/docs/resources/server/datamaps/index.md index 20b024d88..f8a4633a6 100644 --- a/docs/resources/server/datamaps/index.md +++ b/docs/resources/server/datamaps/index.md @@ -36,18 +36,18 @@ For example, let's assume that we have a data map object with two float keys `am ```json5 { - "values": { - // Attach a value to the carrot item - "minecraft:carrot": { - "amount": 12, - "chance": 1 - }, - // Attach a value to all items in the logs tag - "#minecraft:logs": { - "amount": 1, - "chance": 0.1 + "values": { + // Attach a value to the carrot item + "minecraft:carrot": { + "amount": 12, + "chance": 1 + }, + // Attach a value to all items in the logs tag + "#minecraft:logs": { + "amount": 1, + "chance": 0.1 + } } - } } ``` @@ -55,18 +55,18 @@ Data maps may support [mergers][mergers], which will cause custom merging behavi ```json5 { - "values": { - // Overwrite the value of the carrot item - "minecraft:carrot": { - // highlight-next-line - "replace": true, - // The new value will be under a value sub-object - "value": { - "amount": 12, - "chance": 1 - } + "values": { + // Overwrite the value of the carrot item + "minecraft:carrot": { + // highlight-next-line + "replace": true, + // The new value will be under a value sub-object + "value": { + "amount": 12, + "chance": 1 + } + } } - } } ``` @@ -76,10 +76,10 @@ Removing elements can be done by specifying a list of item IDs or tag IDs to rem ```json5 { - // We do not want the potato to have a value, even if another mod's data map added it - "remove": [ - "minecraft:potato" - ] + // We do not want the potato to have a value, even if another mod's data map added it + "remove": [ + "minecraft:potato" + ] } ``` @@ -87,13 +87,13 @@ Removals run after additions, so we can include a tag and then exclude certain e ```json5 { - "values": { - "#minecraft:logs": { /* ... */ } - }, - // Exclude crimson stem again - "remove": [ - "minecraft:crimson_stem" - ] + "values": { + "#minecraft:logs": { /* ... */ } + }, + // Exclude crimson stem again + "remove": [ + "minecraft:crimson_stem" + ] } ``` @@ -101,11 +101,11 @@ Data maps may support custom [removers] with additional arguments. To supply the ```json5 { - "remove": { - // The remover will be deserialized from the value (`somekey1` in this case) - // and applied to the value attached to the carrot item - "minecraft:carrot": "somekey1" - } + "remove": { + // The remover will be deserialized from the value (`somekey1` in this case) + // and applied to the value attached to the carrot item + "minecraft:carrot": "somekey1" + } } ``` @@ -263,12 +263,12 @@ With this remover in mind, consider the following data file: ```json5 { - "values": { - "minecraft:carrot": { - "somekey1": "value1", - "somekey2": "value2" + "values": { + "minecraft:carrot": { + "somekey1": "value1", + "somekey2": "value2" + } } - } } ``` @@ -276,11 +276,11 @@ Now, consider this second data file that is placed at a higher priority than the ```json5 { - "remove": { - // As the remover is decoded as a string, we can use a string as the value here. - // If it were decoded as an object, we would have needed to use an object. - "minecraft:carrot": "somekey1" - } + "remove": { + // As the remover is decoded as a string, we can use a string as the value here. + // If it were decoded as an object, we would have needed to use an object. + "minecraft:carrot": "somekey1" + } } ``` @@ -288,11 +288,11 @@ That way, after both files are applied, the final result will be (an in-memory r ```json5 { - "values": { - "minecraft:carrot": { - "somekey1": "value1" + "values": { + "minecraft:carrot": { + "somekey1": "value1" + } } - } } ``` @@ -338,26 +338,26 @@ This would then result in the following JSON file: ```json5 { - "replace": true, - "values": { - "#minecraft:slabs": { - "amount": 10, - "chance": 1.0 + "replace": true, + "values": { + "#minecraft:slabs": { + "amount": 10, + "chance": 1.0 + }, + "minecraft:apple": { + "amount": 5, + "chance": 0.2 + } }, - "minecraft:apple": { - "amount": 5, - "chance": 0.2 - } - }, - "remove": [ - "#minecraft:wooden_slabs" - ], - "neoforge:conditions": [ - { - "type": "neoforge:mod_loaded", - "modid": "botania" - } - ] + "remove": [ + "#minecraft:wooden_slabs" + ], + "neoforge:conditions": [ + { + "type": "neoforge:mod_loaded", + "modid": "botania" + } + ] } ``` diff --git a/docs/resources/server/enchantments/builtin.md b/docs/resources/server/enchantments/builtin.md index dcd15a573..75fdafc68 100644 --- a/docs/resources/server/enchantments/builtin.md +++ b/docs/resources/server/enchantments/builtin.md @@ -21,31 +21,31 @@ Value effect components can be set to use any of these operations on their given The Sharpness enchantment uses `minecraft:damage`, a value effect component, as follows to achieve its effect: - + ```json5 "effects": { - // The type of this effect component is "minecraft:damage". - // This means that the effect will modify weapon damage. - // See below for a list of more effect component types. - "minecraft:damage": [ - { - // A value effect that should be applied. - // In this case, since there's only one, this value effect is just named "effect". - "effect": { - // The type of value effect to use. In this case, it is "minecraft:add", so the value (given below) will be added - // to the weapon damage value. - "type": "minecraft:add", - - // The value block. In this case, the value is a LevelBasedValue that starts at 1 and increases by 0.5 every enchantment level. - "value": { - "type": "minecraft:linear", - "base": 1.0, - "per_level_above_first": 0.5 + // The type of this effect component is "minecraft:damage". + // This means that the effect will modify weapon damage. + // See below for a list of more effect component types. + "minecraft:damage": [ + { + // A value effect that should be applied. + // In this case, since there's only one, this value effect is just named "effect". + "effect": { + // The type of value effect to use. In this case, it is "minecraft:add", so the value (given below) will be added + // to the weapon damage value. + "type": "minecraft:add", + + // The value block. In this case, the value is a LevelBasedValue that starts at 1 and increases by 0.5 every enchantment level. + "value": { + "type": "minecraft:linear", + "base": 1.0, + "per_level_above_first": 0.5 + } + } } - } - } - ] + ] } ``` @@ -128,27 +128,27 @@ Location based effect components are components that implement `EnchantmentLocat Here is an example which uses the `minecraft:attributes` location based effect component type to change the wielder's entity scale: - + ```json5 // The type is "minecraft:attributes" (described below). // In a nutshell, this applies an attribute modifier. "minecraft:attributes": [ - { - // This "amount" block is a LevelBasedValue. - "amount": { - "type": "minecraft:linear", - "base": 1, - "per_level_above_first": 1 - }, - - // Which attribute to modify. In this case, modifies "minecraft:scale" - "attribute": "minecraft:generic.scale", - // The unique identifier for this attribute modifier. Should not overlap with others, but doesn't need to be registered. - "id": "examplemod:enchantment.size_change", - // What operation to use on the attribute. Can be "add_value", "add_multiplied_base", or "add_multiplied_total". - "operation": "add_value" - } + { + // This "amount" block is a LevelBasedValue. + "amount": { + "type": "minecraft:linear", + "base": 1, + "per_level_above_first": 1 + }, + + // Which attribute to modify. In this case, modifies "minecraft:scale" + "attribute": "minecraft:generic.scale", + // The unique identifier for this attribute modifier. Should not overlap with others, but doesn't need to be registered. + "id": "examplemod:enchantment.size_change", + // What operation to use on the attribute. Can be "add_value", "add_multiplied_base", or "add_multiplied_total". + "operation": "add_value" + } ], ``` @@ -218,33 +218,33 @@ Here is an example of the JSON definition of one such component from the Fire As ```json5 // This component's type is "minecraft:post_attack" (see below). "minecraft:post_attack": [ - { - // Decides whether the "victim" of the attack, the "attacker", or the "damaging entity" (the projectile if there is one, attacker if not) recieves the effect. - "affected": "victim", - - // Decides which enchantment entity effect to apply. - "effect": { - // The type of this effect is "minecraft:ignite". - "type": "minecraft:ignite", - // "minecraft:ignite" requires a LevelBasedValue as a duration for how long the entity will be ignited. - "duration": { - "type": "minecraft:linear", - "base": 4.0, - "per_level_above_first": 4.0 - } - }, - - // Decides who (the "victim", "attacker", or "damaging entity") must have the enchantment for it to take effect. - "enchanted": "attacker", - - // An optional predicate which controls whether the effect applies. - "requirements": { - "condition": "minecraft:damage_source_properties", - "predicate": { - "is_direct": true - } + { + // Decides whether the "victim" of the attack, the "attacker", or the "damaging entity" (the projectile if there is one, attacker if not) recieves the effect. + "affected": "victim", + + // Decides which enchantment entity effect to apply. + "effect": { + // The type of this effect is "minecraft:ignite". + "type": "minecraft:ignite", + // "minecraft:ignite" requires a LevelBasedValue as a duration for how long the entity will be ignited. + "duration": { + "type": "minecraft:linear", + "base": 4.0, + "per_level_above_first": 4.0 + } + }, + + // Decides who (the "victim", "attacker", or "damaging entity") must have the enchantment for it to take effect. + "enchanted": "attacker", + + // An optional predicate which controls whether the effect applies. + "requirements": { + "condition": "minecraft:damage_source_properties", + "predicate": { + "is_direct": true + } + } } - } ] ``` diff --git a/docs/resources/server/enchantments/index.md b/docs/resources/server/enchantments/index.md index 3a9286a6e..fb1faef8c 100644 --- a/docs/resources/server/enchantments/index.md +++ b/docs/resources/server/enchantments/index.md @@ -11,85 +11,85 @@ A new enchantment can be added by creating a JSON file in your namespace's `ench ```json5 { - // The text component that will be used as the in-game name of the enchantment. - // Can be a translation key or a literal string. - // Remember to translate this in your lang file if you use a translation key! - "description": { - "translate": "enchantment.examplemod.enchant_name" - }, - - // Which items this enchantment can be applied to. - // Can be either an item id, such as "minecraft:trident", - // or a list of item ids, such as ["examplemod:red_sword", "examplemod:blue_sword"] - // or an item tag, such as "#examplemod:enchantable/enchant_name". - // Note that this doesn't cause the enchantment to appear for these items in the enchanting table. - "supported_items": "#examplemod:enchantable/enchant_name", - - // (Optional) Which items this enchantment appears for in the enchanting table. - // Can be an item, list of items, or item tag. - // If left unspecified, this is the same as `supported_items`. - "primary_items": [ - "examplemod:item_a", - "examplemod:item_b" - ], - - // (Optional) Which enchantments are incompatible with this one. - // Can be an enchantment id, such as "minecraft:sharpness", - // or a list of enchantment ids, such as ["minecraft:sharpness", "minecraft:fire_aspect"], - // or enchantment tag, such as "#examplemod:exclusive_to_enchant_name". - // Incompatible enchantments will not be added to the same item by vanilla mechanics. - "exclusive_set": "#examplemod:exclusive_to_enchant_name", - - // The likelihood that this enchantment will appear in the Enchanting Table. - // Bounded by [1, 1024]. - "weight": 6, - - // The maximum level this enchantment is allowed to reach. - // Bounded by [1, 255]. - "max_level": 3, - - // The maximum cost of this enchantment, measured in "enchanting power". - // This corresponds to, but is not equivalent to, the threshold in levels the player needs to meet to bestow this enchantment. - // See below for details. - // The actual cost will be between this and the min_cost. - "max_cost": { - "base": 45, - "per_level_above_first": 9 - }, - - // Specifies the minimum cost of this enchantment; otherwise as above. - "min_cost": { - "base": 2, - "per_level_above_first": 8 - }, - - // The cost that this enchantment adds to repairing an item in an anvil in levels. The cost is multiplied by enchantment level. - // If an item has a DataComponentTypes.STORED_ENCHANTMENTS component, the cost is halved. In vanilla, this only applies to enchanted books. - // Bounded by [1, inf). - "anvil_cost": 2, - - // (Optional) A list of slot groups this enchantment provides effects in. - // A slot group is defined as one of the possible values of the EquipmentSlotGroup enum. - // In vanilla, these are: `any`, `hand`, `mainhand`, `offhand`, `armor`, `feet`, `legs`, `chest`, `head`, and `body`. - "slots": [ - "mainhand" - ], - - // The effects that this enchantment provides as a map of enchantment effect components (read on). - "effects": { - "examplemod:custom_effect": [ - { - "effect": { - "type": "minecraft:add", - "value": { - "type": "minecraft:linear", - "base": 1, - "per_level_above_first": 1 - } - } - } - ] - } + // The text component that will be used as the in-game name of the enchantment. + // Can be a translation key or a literal string. + // Remember to translate this in your lang file if you use a translation key! + "description": { + "translate": "enchantment.examplemod.enchant_name" + }, + + // Which items this enchantment can be applied to. + // Can be either an item id, such as "minecraft:trident", + // or a list of item ids, such as ["examplemod:red_sword", "examplemod:blue_sword"] + // or an item tag, such as "#examplemod:enchantable/enchant_name". + // Note that this doesn't cause the enchantment to appear for these items in the enchanting table. + "supported_items": "#examplemod:enchantable/enchant_name", + + // (Optional) Which items this enchantment appears for in the enchanting table. + // Can be an item, list of items, or item tag. + // If left unspecified, this is the same as `supported_items`. + "primary_items": [ + "examplemod:item_a", + "examplemod:item_b" + ], + + // (Optional) Which enchantments are incompatible with this one. + // Can be an enchantment id, such as "minecraft:sharpness", + // or a list of enchantment ids, such as ["minecraft:sharpness", "minecraft:fire_aspect"], + // or enchantment tag, such as "#examplemod:exclusive_to_enchant_name". + // Incompatible enchantments will not be added to the same item by vanilla mechanics. + "exclusive_set": "#examplemod:exclusive_to_enchant_name", + + // The likelihood that this enchantment will appear in the Enchanting Table. + // Bounded by [1, 1024]. + "weight": 6, + + // The maximum level this enchantment is allowed to reach. + // Bounded by [1, 255]. + "max_level": 3, + + // The maximum cost of this enchantment, measured in "enchanting power". + // This corresponds to, but is not equivalent to, the threshold in levels the player needs to meet to bestow this enchantment. + // See below for details. + // The actual cost will be between this and the min_cost. + "max_cost": { + "base": 45, + "per_level_above_first": 9 + }, + + // Specifies the minimum cost of this enchantment; otherwise as above. + "min_cost": { + "base": 2, + "per_level_above_first": 8 + }, + + // The cost that this enchantment adds to repairing an item in an anvil in levels. The cost is multiplied by enchantment level. + // If an item has a DataComponentTypes.STORED_ENCHANTMENTS component, the cost is halved. In vanilla, this only applies to enchanted books. + // Bounded by [1, inf). + "anvil_cost": 2, + + // (Optional) A list of slot groups this enchantment provides effects in. + // A slot group is defined as one of the possible values of the EquipmentSlotGroup enum. + // In vanilla, these are: `any`, `hand`, `mainhand`, `offhand`, `armor`, `feet`, `legs`, `chest`, `head`, and `body`. + "slots": [ + "mainhand" + ], + + // The effects that this enchantment provides as a map of enchantment effect components (read on). + "effects": { + "examplemod:custom_effect": [ + { + "effect": { + "type": "minecraft:add", + "value": { + "type": "minecraft:linear", + "base": 1, + "per_level_above_first": 1 + } + } + } + ] + } } ``` @@ -207,7 +207,7 @@ Enchantment JSON files can be created automatically using the [data generation] For more information on how `RegistrySetBuilder` and `DatapackBuiltinEntriesProvider` work, please see the article on [Data Generation for Datapack Registries]. - + ```java @@ -266,47 +266,47 @@ BUILDER.add( - + ```json5 // For more detail on each entry, please check the section above on the enchantment JSON format. { - // The anvil cost of the enchantment. - "anvil_cost": 2, - - // The text Component that specifies the enchantment's name. - "description": "Example Enchantment", - - // A map of the effect components associated with this enchantment and their values. - "effects": { - - }, - - // The maximum cost of the enchantment. - "max_cost": { - "base": 4, - "per_level_above_first": 2 - }, - - // The maximum level this enchantment can be. - "max_level": 3, - - // The minimum cost of the enchantment. - "min_cost": { - "base": 3, - "per_level_above_first": 1 - }, - - // A list of EquipmentSlotGroup aliases that this enchantment has effects in. - "slots": [ - "any" - ], - - // The set of items that this enchantment can be applied to using an anvil. - "supported_items": , - - // The weight of this enchantment. - "weight": 30 + // The anvil cost of the enchantment. + "anvil_cost": 2, + + // The text Component that specifies the enchantment's name. + "description": "Example Enchantment", + + // A map of the effect components associated with this enchantment and their values. + "effects": { + // + }, + + // The maximum cost of the enchantment. + "max_cost": { + "base": 4, + "per_level_above_first": 2 + }, + + // The maximum level this enchantment can be. + "max_level": 3, + + // The minimum cost of the enchantment. + "min_cost": { + "base": 3, + "per_level_above_first": 1 + }, + + // A list of EquipmentSlotGroup aliases that this enchantment has effects in. + "slots": [ + "any" + ], + + // The set of items that this enchantment can be applied to using an anvil. + "supported_items": /* */, + + // The weight of this enchantment. + "weight": 30 } ``` diff --git a/docs/resources/server/loottables/glm.md b/docs/resources/server/loottables/glm.md index 31af786e1..82fcb8d73 100644 --- a/docs/resources/server/loottables/glm.md +++ b/docs/resources/server/loottables/glm.md @@ -22,13 +22,13 @@ Example usage: ```json5 { - "replace": false, // must be present - "entries": [ - // represents a loot modifier in data/examplemod/loot_modifiers/example_glm_1.json - "examplemod:example_glm_1", - "examplemod:example_glm_2" - // ... - ] + "replace": false, // must be present + "entries": [ + // represents a loot modifier in data/examplemod/loot_modifiers/example_glm_1.json + "examplemod:example_glm_1", + "examplemod:example_glm_2" + // ... + ] } ``` @@ -48,15 +48,15 @@ An example usage may look something like this: ```json5 { - // This is the registry name of the loot modifier - "type": "examplemod:my_loot_modifier", - "conditions": [ - // Loot table conditions here - ], - // Extra properties specified by the codec - "field1": "somestring", - "field2": 10, - "field3": "minecraft:dirt" + // This is the registry name of the loot modifier + "type": "examplemod:my_loot_modifier", + "conditions": [ + // Loot table conditions here + ], + // Extra properties specified by the codec + "field1": "somestring", + "field2": 10, + "field3": "minecraft:dirt" } ``` @@ -137,9 +137,9 @@ This loot modifier rolls a second loot table and adds the results to the loot ta ```json5 { - "type": "neoforge:add_table", - "conditions": [], // the required loot conditions - "table": "minecraft:chests/abandoned_mineshaft" // the second table to roll + "type": "neoforge:add_table", + "conditions": [], // the required loot conditions + "table": "minecraft:chests/abandoned_mineshaft" // the second table to roll } ``` diff --git a/docs/resources/server/loottables/index.md b/docs/resources/server/loottables/index.md index 737e24a77..296f35820 100644 --- a/docs/resources/server/loottables/index.md +++ b/docs/resources/server/loottables/index.md @@ -164,40 +164,40 @@ An example loot table could have the following format: ```json5 { - "type": "chest", // loot parameter set - "neoforge:conditions": [ - // data load conditions - ], - "functions": [ - // table-wide loot functions - ], - "pools": [ // list of loot pools - { - "rolls": 1, // amount of rolls of the loot table, using 5 here will yield 5 results from the pool - "bonus_rolls": 0.5, // amount of bonus rolls - "name": "my_pool", - "conditions": [ - // pool-wide loot conditions - ], - "functions": [ - // pool-wide loot functions - ], - "entries": [ // list of loot table entries + "type": "chest", // loot parameter set + "neoforge:conditions": [ + // data load conditions + ], + "functions": [ + // table-wide loot functions + ], + "pools": [ // list of loot pools { - "type": "minecraft:item", // loot entry type - "name": "minecraft:dirt", // type-specific properties, for example the name of the item - "weight": 3, // weight of an entry - "quality": 1, // quality of an entry - "conditions": [ - // entry-wide loot conditions - ], - "functions": [ - // entry-wide loot functions - ] + "rolls": 1, // amount of rolls of the loot table, using 5 here will yield 5 results from the pool + "bonus_rolls": 0.5, // amount of bonus rolls + "name": "my_pool", + "conditions": [ + // pool-wide loot conditions + ], + "functions": [ + // pool-wide loot functions + ], + "entries": [ // list of loot table entries + { + "type": "minecraft:item", // loot entry type + "name": "minecraft:dirt", // type-specific properties, for example the name of the item + "weight": 3, // weight of an entry + "quality": 1, // quality of an entry + "conditions": [ + // entry-wide loot conditions + ], + "functions": [ + // entry-wide loot functions + ] + } + ] } - ] - } - ] + ] } ``` diff --git a/docs/resources/server/loottables/lootconditions.md b/docs/resources/server/loottables/lootconditions.md index fddb6870d..fce74fe25 100644 --- a/docs/resources/server/loottables/lootconditions.md +++ b/docs/resources/server/loottables/lootconditions.md @@ -8,10 +8,10 @@ This condition accepts another condition and inverts its result. Requires whatev ```json5 { - "condition": "minecraft:inverted", - "term": { - // Some other loot condition. - } + "condition": "minecraft:inverted", + "term": { + // Some other loot condition. + } } ``` @@ -23,18 +23,18 @@ This condition accepts any number of other conditions and returns true if all su ```json5 { - "condition": "minecraft:all_of", - "terms": [ - { - // A loot condition. - }, - { - // Another loot condition. - }, - { - // Yet another loot condition. - } - ] + "condition": "minecraft:all_of", + "terms": [ + { + // A loot condition. + }, + { + // Another loot condition. + }, + { + // Yet another loot condition. + } + ] } ``` @@ -46,18 +46,18 @@ This condition accepts any number of other conditions and returns true if at lea ```json5 { - "condition": "minecraft:any_of", - "terms": [ - { - // A loot condition. - }, - { - // Another loot condition. - }, - { - // Yet another loot condition. - } - ] + "condition": "minecraft:any_of", + "terms": [ + { + // A loot condition. + }, + { + // Another loot condition. + }, + { + // Yet another loot condition. + } + ] } ``` @@ -69,9 +69,9 @@ This condition accepts a [number provider][numberprovider] representing a chance ```json5 { - "condition": "minecraft:random_chance", - // A constant 50% chance for the condition to apply. - "chance": 0.5 + "condition": "minecraft:random_chance", + // A constant 50% chance for the condition to apply. + "chance": 0.5 } ``` @@ -83,16 +83,16 @@ This condition accepts an enchantment id, a [`LevelBasedValue`][numberprovider] ```json5 { - "condition": "minecraft:random_chance_with_enchanted_bonus", - // Add a 20% chance per looting level to succeed. - "enchantment": "minecraft:looting", - "enchanted_chance": { - "type": "linear", - "base": 0.2, - "per_level_above_first": 0.2 - }, - // Always fail if the looting enchantment is not present. - "unenchanted_chance": 0.0 + "condition": "minecraft:random_chance_with_enchanted_bonus", + // Add a 20% chance per looting level to succeed. + "enchantment": "minecraft:looting", + "enchanted_chance": { + "type": "linear", + "base": 0.2, + "per_level_above_first": 0.2 + }, + // Always fail if the looting enchantment is not present. + "unenchanted_chance": 0.0 } ``` @@ -104,18 +104,18 @@ This condition accepts a [number provider][numberprovider] and an `IntRange`, re ```json5 { - "condition": "minecraft:value_check", - // May be any number provider. - "value": { - "type": "minecraft:uniform", - "min": 0.0, - "max": 10.0 - }, - // A range with min/max values. - "range": { - "min": 2.0, - "max": 5.0 - } + "condition": "minecraft:value_check", + // May be any number provider. + "value": { + "type": "minecraft:uniform", + "min": 0.0, + "max": 10.0 + }, + // A range with min/max values. + "range": { + "min": 2.0, + "max": 5.0 + } } ``` @@ -127,16 +127,16 @@ This condition checks if the world time is within an `IntRange`. Optionally, a ` ```json5 { - "condition": "minecraft:time_check", - // Optional, can be omitted. If omitted, no modulo operation will take place. - // We use 24000 here, which is the length of one in-game day/night cycle. - "period": 24000, - // A range with min/max values. This example checks if the time is between 0 and 12000. - // Combined with the modulo operand of 24000 specified above, this example checks if it is currently daytime. - "value": { - "min": 0, - "max": 12000 - } + "condition": "minecraft:time_check", + // Optional, can be omitted. If omitted, no modulo operation will take place. + // We use 24000 here, which is the length of one in-game day/night cycle. + "period": 24000, + // A range with min/max values. This example checks if the time is between 0 and 12000. + // Combined with the modulo operand of 24000 specified above, this example checks if it is currently daytime. + "value": { + "min": 0, + "max": 12000 + } } ``` @@ -148,13 +148,13 @@ This condition checks the current weather for raining and thundering. ```json5 { - "condition": "minecraft:weather_check", - // Optional. If unspecified, the rain state will not be checked. - "raining": true, - // Optional. If unspecified, the thundering state will not be checked. - // Specifying "raining": true and "thundering": true is functionally equivalent to just specifying - // "thundering": true, since it is always raining when a thunderstorm occurs. - "thundering": false + "condition": "minecraft:weather_check", + // Optional. If unspecified, the rain state will not be checked. + "raining": true, + // Optional. If unspecified, the thundering state will not be checked. + // Specifying "raining": true and "thundering": true is functionally equivalent to just specifying + // "thundering": true, since it is always raining when a thunderstorm occurs. + "thundering": false } ``` @@ -166,16 +166,16 @@ This condition accepts a `LocationPredicate` and an optional offset value for ea ```json5 { - "condition": "minecraft:location_check", - "predicate": { - // Succeed if our target is anywhere in the nether. - "dimension": "the_nether" - }, - // Optional position offset values. Only relevant if you are checking the position in some way. - // Must either be provided all at once, or not at all. - "offsetX": 10, - "offsetY": 10, - "offsetZ": 10 + "condition": "minecraft:location_check", + "predicate": { + // Succeed if our target is anywhere in the nether. + "dimension": "the_nether" + }, + // Optional position offset values. Only relevant if you are checking the position in some way. + // Must either be provided all at once, or not at all. + "offsetX": 10, + "offsetY": 10, + "offsetZ": 10 } ``` @@ -187,15 +187,15 @@ This condition checks for the specified block state properties to have the speci ```json5 { - "condition": "minecraft:block_state_property", - // The expected block. If this does not match the block that is actually broken, the condition fails. - "block": "minecraft:oak_slab", - // The block state properties to match. Unspecified properties can have either value. - // In this example, we want to only succeed if a top slab - waterlogged or not - is broken. - // If this specifies properties not present on the block, a log warning will be printed. - "properties": { - "type": "top" - } + "condition": "minecraft:block_state_property", + // The expected block. If this does not match the block that is actually broken, the condition fails. + "block": "minecraft:oak_slab", + // The block state properties to match. Unspecified properties can have either value. + // In this example, we want to only succeed if a top slab - waterlogged or not - is broken. + // If this specifies properties not present on the block, a log warning will be printed. + "properties": { + "type": "top" + } } ``` @@ -207,7 +207,7 @@ This condition randomly destroys the drops. The chance for drops to survive is 1 ```json5 { - "condition": "minecraft:survives_explosion" + "condition": "minecraft:survives_explosion" } ``` @@ -219,14 +219,14 @@ This condition accepts an `ItemPredicate` that is checked against the `tool` loo ```json5 { - "condition": "minecraft:match_tool", - // Match a netherite pickaxe or axe. - "predicate": { - "items": [ - "minecraft:netherite_pickaxe", - "minecraft:netherite_axe" - ] - } + "condition": "minecraft:match_tool", + // Match a netherite pickaxe or axe. + "predicate": { + "items": [ + "minecraft:netherite_pickaxe", + "minecraft:netherite_axe" + ] + } } ``` @@ -238,9 +238,9 @@ This condition returns whether an enchantment is active or not. Requires the `mi ```json5 { - "condition": "minecraft:enchantment_active", - // Whether the enchantment should be active (true) or not (false). - "active": true + "condition": "minecraft:enchantment_active", + // Whether the enchantment should be active (true) or not (false). + "active": true } ``` @@ -252,12 +252,12 @@ This condition is similar to `minecraft:random_chance_with_enchanted_bonus`, but ```json5 { - "condition": "minecraft:table_bonus", - // Apply the bonus if the fortune enchantment is present. - "enchantment": "minecraft:fortune", - // The chances to use per level. This example has a 20% chance of succeeding if unenchanted, - // 30% if enchanted at level 1, and 60% if enchanted at level 2 or above. - "chances": [0.2, 0.3, 0.6] + "condition": "minecraft:table_bonus", + // Apply the bonus if the fortune enchantment is present. + "enchantment": "minecraft:fortune", + // The chances to use per level. This example has a 20% chance of succeeding if unenchanted, + // 30% if enchanted at level 1, and 60% if enchanted at level 2 or above. + "chances": [0.2, 0.3, 0.6] } ``` @@ -269,16 +269,16 @@ This condition checks a given `EntityPredicate` against an [entity target][entit ```json5 { - "condition": "minecraft:entity_properties", - // The entity target to use. Valid values are "this", "attacker", "direct_attacker" or "attacking_player". - // These correspond to the "this_entity", "attacking_entity", "direct_attacking_entity" and - // "last_damage_player" loot parameters, respectively. - "entity": "attacker", - // Only succeed if the target is a pig. The predicate may also be empty, this can be used - // to check whether the specified entity target is set at all. - "predicate": { - "type": "minecraft:pig" - } + "condition": "minecraft:entity_properties", + // The entity target to use. Valid values are "this", "attacker", "direct_attacker" or "attacking_player". + // These correspond to the "this_entity", "attacking_entity", "direct_attacking_entity" and + // "last_damage_player" loot parameters, respectively. + "entity": "attacker", + // Only succeed if the target is a pig. The predicate may also be empty, this can be used + // to check whether the specified entity target is set at all. + "predicate": { + "type": "minecraft:pig" + } } ``` @@ -290,13 +290,13 @@ This condition checks a given `DamageSourcePredicate` against the damage source ```json5 { - "condition": "minecraft:damage_source_properties", - "predicate": { - // Check whether the source entity is a zombie. - "source_entity": { - "type": "zombie" + "condition": "minecraft:damage_source_properties", + "predicate": { + // Check whether the source entity is a zombie. + "source_entity": { + "type": "zombie" + } } - } } ``` @@ -308,7 +308,7 @@ This condition determines whether the kill was a player kill. Used by some entit ```json5 { - "condition": "minecraft:killed_by_player" + "condition": "minecraft:killed_by_player" } ``` @@ -320,22 +320,22 @@ This condition checks the [entity target][entitytarget]'s scoreboard. Requires t ```json5 { - "condition": "minecraft:entity_scores" - // The entity target to use. Valid values are "this", "attacker", "direct_attacker" or "attacking_player". - // These correspond to the "this_entity", "attacking_entity", "direct_attacking_entity" and - // "last_damage_player" loot parameters, respectively. - "entity": "attacker", - // A list of scoreboard values that must be in the given ranges. - "scores": { - "score1": { - "min": 0, - "max": 100 - }, - "score2": { - "min": 10, - "max": 20 + "condition": "minecraft:entity_scores" + // The entity target to use. Valid values are "this", "attacker", "direct_attacker" or "attacking_player". + // These correspond to the "this_entity", "attacking_entity", "direct_attacking_entity" and + // "last_damage_player" loot parameters, respectively. + "entity": "attacker", + // A list of scoreboard values that must be in the given ranges. + "scores": { + "score1": { + "min": 0, + "max": 100 + }, + "score2": { + "min": 10, + "max": 20 + } } - } } ``` @@ -347,9 +347,9 @@ This condition references a predicate file and returns its result. See [Item Pre ```json5 { - "condition": "minecraft:reference", - // Refers to the predicate file at data/examplemod/predicate/example_predicate.json. - "name": "examplemod:example_predicate" + "condition": "minecraft:reference", + // Refers to the predicate file at data/examplemod/predicate/example_predicate.json. + "name": "examplemod:example_predicate" } ``` @@ -361,9 +361,9 @@ This condition only returns true if the surrounding loot table id matches. This ```json5 { - "condition": "neoforge:loot_table_id", - // Will only apply when the loot table is for dirt - "loot_table_id": "minecraft:blocks/dirt" + "condition": "neoforge:loot_table_id", + // Will only apply when the loot table is for dirt + "loot_table_id": "minecraft:blocks/dirt" } ``` @@ -375,9 +375,9 @@ This condition only returns true if the item in the `tool` loot context paramete ```json5 { - "condition": "neoforge:can_item_perform_ability", - // Will only apply if the tool can strip a log like an axe - "ability": "axe_strip" + "condition": "neoforge:can_item_perform_ability", + // Will only apply if the tool can strip a log like an axe + "ability": "axe_strip" } ``` diff --git a/docs/resources/server/loottables/lootfunctions.md b/docs/resources/server/loottables/lootfunctions.md index 8b5190564..5d508d3e8 100644 --- a/docs/resources/server/loottables/lootfunctions.md +++ b/docs/resources/server/loottables/lootfunctions.md @@ -14,9 +14,9 @@ Sets a different item to use in the result item stack. ```json5 { - "function": "minecraft:set_item", - // The item to use. - "item": "minecraft:dirt" + "function": "minecraft:set_item", + // The item to use. + "item": "minecraft:dirt" } ``` @@ -28,15 +28,15 @@ Sets an item count to use in the result item stack. Uses a [number provider][num ```json5 { - "function": "minecraft:set_count", - // The count to use. - "count": { - "type": "minecraft:uniform", - "min": 1, - "max": 3 - }, - // Whether to add to the existing value instead of setting it. Optional, defaults to false. - "add": true + "function": "minecraft:set_count", + // The count to use. + "count": { + "type": "minecraft:uniform", + "min": 1, + "max": 3 + }, + // Whether to add to the existing value instead of setting it. Optional, defaults to false. + "add": true } ``` @@ -48,7 +48,7 @@ Applies an explosion decay. The item has a chance of 1 / `explosion_radius` to " ```json5 { - "function": "minecraft:explosion_decay" + "function": "minecraft:explosion_decay" } ``` @@ -60,11 +60,11 @@ Clamps the count of the item stack between a given `IntRange`. ```json5 { - "function": "minecraft:limit_count", - // The limit to use. Can have a min, a max, or both. - "limit": { - "max": 32 - } + "function": "minecraft:limit_count", + // The limit to use. Can have a min, a max, or both. + "limit": { + "max": 32 + } } ``` @@ -76,10 +76,10 @@ Sets custom NBT data on the item stack. ```json5 { - "function": "minecraft:set_custom_data", - "tag": { - "exampleproperty": 0 - } + "function": "minecraft:set_custom_data", + "tag": { + "exampleproperty": 0 + } } ``` @@ -95,26 +95,26 @@ Copies custom NBT data from a block entity or entity source to the item stack. U ```json5 { - "function": "minecraft:copy_custom_data", - // The source to use. Valid values are either an entity target, "block_entity" to use the loot context's - // block entity parameter, or be "storage" for command storage. If this is "storage", it can instead be a - // JSON object that additionally specify the command storage path to be used. - "source": "this", - // Example for using "storage". - "source": { - "type": "storage", - "source": "examplepath" - }, - // The copy operation(s). - "ops": [ - { - // The source and target paths. In this example, we copy from "src" in the source to "dest" in the target. - "source": "src", - "target": "dest", - // A merging strategy. Valid values are "replace", "append", and "merge". - "op": "merge" - } - ] + "function": "minecraft:copy_custom_data", + // The source to use. Valid values are either an entity target, "block_entity" to use the loot context's + // block entity parameter, or be "storage" for command storage. If this is "storage", it can instead be a + // JSON object that additionally specify the command storage path to be used. + "source": "this", + // Example for using "storage". + "source": { + "type": "storage", + "source": "examplepath" + }, + // The copy operation(s). + "ops": [ + { + // The source and target paths. In this example, we copy from "src" in the source to "dest" in the target. + "source": "src", + "target": "dest", + // A merging strategy. Valid values are "replace", "append", and "merge". + "op": "merge" + } + ] } ``` @@ -126,13 +126,13 @@ Sets [data component][datacomponent] values on the item stack. Most vanilla use ```json5 { - "function": "minecraft:set_components", - // Any component can be used. In this example, we set the dyed color of the item to red. - "components": { - "dyed_color": { - "rgb": 0xff0000 + "function": "minecraft:set_components", + // Any component can be used. In this example, we set the dyed color of the item to red. + "components": { + "dyed_color": { + "rgb": 16711680 + } } - } } ``` @@ -144,13 +144,13 @@ Copies [data component][datacomponent] values from a block entity to the item st ```json5 { - "function": "minecraft:copy_components", - // The system is designed to allow multiple sources, however for now, there are only block entities available. - "source": "block_entity", - // By default, all components are copied. The "exclude" list allows excluding certain components, and the - // "include" list allows explicitly re-including components. Both fields are optional. - "exclude": [], - "include": [] + "function": "minecraft:copy_components", + // The system is designed to allow multiple sources, however for now, there are only block entities available. + "source": "block_entity", + // By default, all components are copied. The "exclude" list allows excluding certain components, and the + // "include" list allows explicitly re-including components. Both fields are optional. + "exclude": [], + "include": [] } ``` @@ -162,13 +162,13 @@ Copies block state properties into the item stack's `block_state` [data componen ```json5 { - "function": "minecraft:copy_state", - // The expected block. If this does not match the block that is actually broken, the function does not run. - "block": "minecraft:oak_slab", - // The block state properties to save. - "properties": { - "type": "top" - } + "function": "minecraft:copy_state", + // The expected block. If this does not match the block that is actually broken, the function does not run. + "block": "minecraft:oak_slab", + // The block state properties to save. + "properties": { + "type": "top" + } } ``` @@ -180,20 +180,20 @@ Sets contents of the item stack. ```json5 { - "function": "minecraft:set_contents", - // The contents component to use. Valid values are "container", "bundle_contents" and "charged_projectiles". - "component": "container", - // A list of loot entries to add to the contents. - "entries": [ - { - "type": "minecraft:empty", - "weight": 3 - }, - { - "type": "minecraft:item", - "item": "minecraft:arrow" - } - ] + "function": "minecraft:set_contents", + // The contents component to use. Valid values are "container", "bundle_contents" and "charged_projectiles". + "component": "container", + // A list of loot entries to add to the contents. + "entries": [ + { + "type": "minecraft:empty", + "weight": 3 + }, + { + "type": "minecraft:item", + "item": "minecraft:arrow" + } + ] } ``` @@ -205,11 +205,11 @@ Applies a function to the contents of the item stack. ```json5 { - "function": "minecraft:modify_contents", - // The contents component to use. Valid values are "container", "bundle_contents" and "charged_projectiles". - "component": "container", - // The function to use. - "modifier": "apply_explosion_decay" + "function": "minecraft:modify_contents", + // The contents component to use. Valid values are "container", "bundle_contents" and "charged_projectiles". + "component": "container", + // The function to use. + "modifier": "apply_explosion_decay" } ``` @@ -221,13 +221,13 @@ Sets a container loot table on the result item stack. Intended for chests and ot ```json5 { - "function": "minecraft:set_loot_table", - // The id of the loot table to use. - "name": "minecraft:entities/enderman", - // The id of the block entity type of the target block entity. - "type": "minecraft:chest", - // The random seed for generating loot tables. Optional, defaults to 0. - "seed": 42 + "function": "minecraft:set_loot_table", + // The id of the loot table to use. + "name": "minecraft:entities/enderman", + // The id of the block entity type of the target block entity. + "type": "minecraft:chest", + // The random seed for generating loot tables. Optional, defaults to 0. + "seed": 42 } ``` @@ -239,13 +239,13 @@ Sets a name for the result item stack. The name can be a [`Component`][component ```json5 { - "function": "minecraft:set_name", - "name": "Funny Item", - // The entity target to use. - "entity": "this", - // Whether to set the custom name ("custom_name") or the item name ("item_name") itself. - // Custom name are displayed in italics and can be changed in an anvil, while item names cannot. - "target": "custom_name" + "function": "minecraft:set_name", + "name": "Funny Item", + // The entity target to use. + "entity": "this", + // Whether to set the custom name ("custom_name") or the item name ("item_name") itself. + // Custom name are displayed in italics and can be changed in an anvil, while item names cannot. + "target": "custom_name" } ``` @@ -257,9 +257,9 @@ Copies an [entity target][entitytarget]'s or block entity's name into the result ```json5 { - "function": "minecraft:copy_name", - // The entity target, or "block_entity" if a block entity's name should be copied. - "source": "this" + "function": "minecraft:copy_name", + // The entity target, or "block_entity" if a block entity's name should be copied. + "source": "this" } ``` @@ -271,25 +271,25 @@ Sets lore (tooltip lines) for the result item stack. The lines can be [`Componen ```json5 { - "function": "minecraft:set_lore", - "lore": [ - "Funny Lore", - "Funny Lore 2" - ], - // The merging mode used. Valid values are: - // - "append": Appends the entries to any existing lore entries. - // - "insert": Inserts the entries at a certain position. The position is denoted as an additional field - // named "offset". "offset" is optional and defaults to 0. - // - "replace_all": Removes all previous entries and then appends the entries. - // - "replace_section": Removes a section of entries and then adds the entries at that position. - // The section removed is denoted through the "offset" and optional "size" fields. - // If "size" is omitted, the amount of lines in "lore" is used. - "mode": { - "type": "insert", - "offset": 0 - }, - // The entity target to use. - "entity": "this" + "function": "minecraft:set_lore", + "lore": [ + "Funny Lore", + "Funny Lore 2" + ], + // The merging mode used. Valid values are: + // - "append": Appends the entries to any existing lore entries. + // - "insert": Inserts the entries at a certain position. The position is denoted as an additional field + // named "offset". "offset" is optional and defaults to 0. + // - "replace_all": Removes all previous entries and then appends the entries. + // - "replace_section": Removes a section of entries and then adds the entries at that position. + // The section removed is denoted through the "offset" and optional "size" fields. + // If "size" is omitted, the amount of lines in "lore" is used. + "mode": { + "type": "insert", + "offset": 0 + }, + // The entity target to use. + "entity": "this" } ``` @@ -301,20 +301,20 @@ Enables or disables certain component tooltips. ```json5 { - "function": "minecraft:toggle_tooltips", - "toggles": { - // All values are optional. If omitted, these values will use pre-existing values on the stack. - // The pre-existing values are generally true, unless they have already been modified by another function. - "minecraft:attribute_modifiers": false, - "minecraft:can_break": false, - "minecraft:can_place_on": false, - "minecraft:dyed_color": false, - "minecraft:enchantments": false, - "minecraft:jukebox_playable": false, - "minecraft:stored_enchantments": false, - "minecraft:trim": false, - "minecraft:unbreakable": false - } + "function": "minecraft:toggle_tooltips", + "toggles": { + // All values are optional. If omitted, these values will use pre-existing values on the stack. + // The pre-existing values are generally true, unless they have already been modified by another function. + "minecraft:attribute_modifiers": false, + "minecraft:can_break": false, + "minecraft:can_place_on": false, + "minecraft:dyed_color": false, + "minecraft:enchantments": false, + "minecraft:jukebox_playable": false, + "minecraft:stored_enchantments": false, + "minecraft:trim": false, + "minecraft:unbreakable": false + } } ``` @@ -325,19 +325,19 @@ It is currently not possible to create this function during datagen. Randomly enchants the item stack with a given amount of levels. Uses a [number provider][numberprovider]. ```json5 -{ - "function": "minecraft:enchant_with_levels", - // The amount of levels to use. - "levels": { - "type": "minecraft:uniform", - "min": 10, - "max": 30 - }, - // A list of possible enchantments. Optional, defaults to all applicable enchantments for the item. - "options": [ - "minecraft:sharpness", - "minecraft:fire_aspect" - ] + { + "function": "minecraft:enchant_with_levels", + // The amount of levels to use. + "levels": { + "type": "minecraft:uniform", + "min": 10, + "max": 30 + }, + // A list of possible enchantments. Optional, defaults to all applicable enchantments for the item. + "options": [ + "minecraft:sharpness", + "minecraft:fire_aspect" + ] } ``` @@ -349,14 +349,14 @@ Enchants the item with one random enchantment. ```json5 { - "function": "minecraft:enchant_randomly", - // A list of possible enchantments. Optional, defaults to all enchantments. - "options": [ - "minecraft:sharpness", - "minecraft:fire_aspect" - ] - // Whether to only allow compatible enchantments, or any enchantments. Optional, defaults to true. - "only_compatible": true + "function": "minecraft:enchant_randomly", + // A list of possible enchantments. Optional, defaults to all enchantments. + "options": [ + "minecraft:sharpness", + "minecraft:fire_aspect" + ] + // Whether to only allow compatible enchantments, or any enchantments. Optional, defaults to true. + "only_compatible": true } ``` @@ -368,18 +368,18 @@ Sets enchantments on the result item stack. ```json5 { - "function": "minecraft:set_enchantments", - // A map of enchantments to number providers. - "enchantments": { - "minecraft:fire_aspect": 2, - "minecraft:sharpness": { - "type": "minecraft:uniform", - "min": 3, - "max": 5, - } - }, - // Whether to add enchantment levels to existing levels instead of overwriting them. Optional, defaults to false. - "add": true + "function": "minecraft:set_enchantments", + // A map of enchantments to number providers. + "enchantments": { + "minecraft:fire_aspect": 2, + "minecraft:sharpness": { + "type": "minecraft:uniform", + "min": 3, + "max": 5, + } + }, + // Whether to add enchantment levels to existing levels instead of overwriting them. Optional, defaults to false. + "add": true } ``` @@ -391,17 +391,17 @@ Increases the item stack count based on the enchantment value. Uses a [number pr ```json5 { - "function": "minecraft:enchanted_count_increase", - // The enchantment to use. - "enchantment": "minecraft:fortune" - // The increase count per level. The number provider is rolled once per function, not once per level. - "count": { - "type": "minecraft:uniform", - "min": 1, - "max": 3 - }, - // The stack size limit, which will not be exceeded no matter the enchantment level. Optional. - "limit": 5 + "function": "minecraft:enchanted_count_increase", + // The enchantment to use. + "enchantment": "minecraft:fortune", + // The increase count per level. The number provider is rolled once per function, not once per level. + "count": { + "type": "minecraft:uniform", + "min": 1, + "max": 3 + }, + // The stack size limit, which will not be exceeded no matter the enchantment level. Optional. + "limit": 5 } ``` @@ -413,20 +413,20 @@ Applies an increase to the item stack count based on the enchantment value and v ```json5 { - "function": "minecraft:apply_bonus", - // The enchantment value to query. - "enchantment": "minecraft:fortune", - // The formula to use. Valid values are: - // - "minecraft:binomial_with_bonus_count": Applies a bonus based on a binomial distribution with - // n = enchantment level + extra and p = probability. - // - "minecraft:ore_drops": Applies a bonus based on a special formula for ore drops, including randomness. - // - "minecraft:uniform_bonus_count": Adds a bonus based on the enchantment level scaled by a constant multiplier. - "formula": "ore_drops", - // The parameter values, depending on the formula. - // If the formula is "minecraft:binomial_with_bonus_count", requires "extra" and "probability". - // If the formula is "minecraft:ore_drops", requires no parameters. - // If the formula is "minecraft:uniform_bonus_count", requires "bonusMultiplier". - "parameters": {} + "function": "minecraft:apply_bonus", + // The enchantment value to query. + "enchantment": "minecraft:fortune", + // The formula to use. Valid values are: + // - "minecraft:binomial_with_bonus_count": Applies a bonus based on a binomial distribution with + // n = enchantment level + extra and p = probability. + // - "minecraft:ore_drops": Applies a bonus based on a special formula for ore drops, including randomness. + // - "minecraft:uniform_bonus_count": Adds a bonus based on the enchantment level scaled by a constant multiplier. + "formula": "ore_drops", + // The parameter values, depending on the formula. + // If the formula is "minecraft:binomial_with_bonus_count", requires "extra" and "probability". + // If the formula is "minecraft:ore_drops", requires no parameters. + // If the formula is "minecraft:uniform_bonus_count", requires "bonusMultiplier". + "parameters": {} } ``` @@ -438,7 +438,7 @@ Attempts to smelt the item as if it were in a furnace, returning the unmodified ```json5 { - "function": "minecraft:furnace_smelt" + "function": "minecraft:furnace_smelt" } ``` @@ -450,15 +450,15 @@ Sets a durability damage value on the result item stack. Uses a [number provider ```json5 { - "function": "minecraft:set_damage", - // The damage to set. - "damage": { - "type": "minecraft:uniform", - "min": 10, - "max": 300 - }, - // Whether to add to the existing damage instead of setting it. Optional, defaults to false. - "add": true + "function": "minecraft:set_damage", + // The damage to set. + "damage": { + "type": "minecraft:uniform", + "min": 10, + "max": 300 + }, + // Whether to add to the existing damage instead of setting it. Optional, defaults to false. + "add": true } ``` @@ -470,28 +470,28 @@ Adds a list of attribute modifiers to the result item stack. ```json5 { - "function": "minecraft:set_attributes", - // A list of attribute modifiers. - "modifiers": [ - { - // The resource location id of the modifier. Should be prefixed by your mod id. - "id": "examplemod:example_modifier", - // The id of the attribute the modifier is for. - "attribute": "minecraft:generic.attack_damage", - // The attribute modifier operation. - // Valid values are "add_value", "add_multiplied_base" and "add_multiplied_total". - "operation": "add_value", - // The amount of the modifier. This can also be a number provider. - "amount": 5, - // The slot(s) the modifier applies for. Valid values are "any" (any inventory slot), - // "mainhand", "offhand", "hand", (mainhand/offhand/both hands), - // "feet", "legs", "chest", "head", "armor" (boots/leggings/chestplates/helmets/any armor slots) - // and "body" (horse armor and similar slots). - "slot": "armor" - } - ], - // Whether to replace the existing values instead of adding to them. Optional, defaults to true. - "replace": false + "function": "minecraft:set_attributes", + // A list of attribute modifiers. + "modifiers": [ + { + // The resource location id of the modifier. Should be prefixed by your mod id. + "id": "examplemod:example_modifier", + // The id of the attribute the modifier is for. + "attribute": "minecraft:generic.attack_damage", + // The attribute modifier operation. + // Valid values are "add_value", "add_multiplied_base" and "add_multiplied_total". + "operation": "add_value", + // The amount of the modifier. This can also be a number provider. + "amount": 5, + // The slot(s) the modifier applies for. Valid values are "any" (any inventory slot), + // "mainhand", "offhand", "hand", (mainhand/offhand/both hands), + // "feet", "legs", "chest", "head", "armor" (boots/leggings/chestplates/helmets/any armor slots) + // and "body" (horse armor and similar slots). + "slot": "armor" + } + ], + // Whether to replace the existing values instead of adding to them. Optional, defaults to true. + "replace": false } ``` @@ -503,9 +503,9 @@ Sets a potion on the result item stack. ```json5 { - "function": "minecraft:set_potion", - // The id of the potion. - "id": "minecraft:strength" + "function": "minecraft:set_potion", + // The id of the potion. + "id": "minecraft:strength" } ``` @@ -517,16 +517,16 @@ Sets a list of stew effects on the result item stack. ```json5 { - "function": "minecraft:set_stew_effect", - // The effects to set. - "effects": [ - { - // The effect id. - "type": "minecraft:fire_resistance", - // The effect duration, in ticks. This can also be a number provider. - "duration": 100 - } - ] + "function": "minecraft:set_stew_effect", + // The effects to set. + "effects": [ + { + // The effect id. + "type": "minecraft:fire_resistance", + // The effect duration, in ticks. This can also be a number provider. + "duration": 100 + } + ] } ``` @@ -538,13 +538,13 @@ Sets an ominous bottle amplifier on the result item stack. Uses a [number provid ```json5 { - "function": "minecraft:set_ominous_bottle_amplifier", - // The amplifier to use. - "amplifier": { - "type": "minecraft:uniform", - "min": 1, - "max": 3 - } + "function": "minecraft:set_ominous_bottle_amplifier", + // The amplifier to use. + "amplifier": { + "type": "minecraft:uniform", + "min": 1, + "max": 3 + } } ``` @@ -556,19 +556,19 @@ Transforms the result item stack into an exploration map if and only if it is a ```json5 { - "function": "minecraft:exploration_map", - // A structure tag, containing the structures an exploration map can lead to. - // Optional, defaults to "minecraft:on_treasure_maps", which only contains buried treasures by default. - "destination": "minecraft:eye_of_ender_located", - // The map decoration type to use. See the MapDecorationTypes class for available values. - // Optional, defaults to "minecraft:mansion". - "decoration": "minecraft:target_x", - // The zoom level to use. Optional, defaults to 2. - "zoom": 4, - // The search radius to use. Optional, defaults to 50. - "search_radius": 25, - // Whether existing chunks are skipped when searching for structures. Optional, defaults to true. - "skip_existing_chunks": true + "function": "minecraft:exploration_map", + // A structure tag, containing the structures an exploration map can lead to. + // Optional, defaults to "minecraft:on_treasure_maps", which only contains buried treasures by default. + "destination": "minecraft:eye_of_ender_located", + // The map decoration type to use. See the MapDecorationTypes class for available values. + // Optional, defaults to "minecraft:mansion". + "decoration": "minecraft:target_x", + // The zoom level to use. Optional, defaults to 2. + "zoom": 4, + // The search radius to use. Optional, defaults to 50. + "search_radius": 25, + // Whether existing chunks are skipped when searching for structures. Optional, defaults to true. + "skip_existing_chunks": true } ``` @@ -580,9 +580,9 @@ Sets the player head owner on the result item stack based on the given [entity t ```json5 { - "function": "minecraft:fill_player_head", - // The entity target to use. If this doesn't resolve to a player, the stack is not modified. - "entity": "this_entity" + "function": "minecraft:fill_player_head", + // The entity target to use. If this doesn't resolve to a player, the stack is not modified. + "entity": "this_entity" } ``` @@ -594,18 +594,18 @@ Sets banner patterns on the result item stack. This is for banners, not banner p ```json5 { - "function": "minecraft:set_banner_patterns", - // A list of banner pattern layers. - "patterns": [ - { - // The id of the banner pattern to use. - "pattern": "minecraft:globe", - // The dye color of the layer. - "color": "light_blue" - } - ], - // Whether to append to the existing layers instead of replacing them. - "append": true + "function": "minecraft:set_banner_patterns", + // A list of banner pattern layers. + "patterns": [ + { + // The id of the banner pattern to use. + "pattern": "minecraft:globe", + // The dye color of the layer. + "color": "light_blue" + } + ], + // Whether to append to the existing layers instead of replacing them. + "append": true } ``` @@ -617,9 +617,9 @@ Sets the instrument tag on the result item stack. ```json5 { - "function": "minecraft:set_instrument", - // The instrument tag to use. - "options": "minecraft:goat_horns" + "function": "minecraft:set_instrument", + // The instrument tag to use. + "options": "minecraft:goat_horns" } ``` @@ -629,31 +629,31 @@ During datagen, call `SetInstrumentFunction#setInstrumentOptions` with the desir ```json5 { - "function": "minecraft:set_fireworks", - // The explosions to use. Optional, uses the existing data component value if absent. - "explosions": [ - { - // The firework explosion shape to use. Valid vanilla values are "small_ball", "large_ball", - // "star", "creeper" and "burst". Optional, defaults to "small_ball". - "shape": "star", - // The colors to use. Optional, defaults to an empty list. - "colors": [ - 0xff0000, - 0x00ff00 - ] - // The fade colors to use. Optional, defaults to an empty list. - "fade_colors": [ - 0x00ff00, - 0x0000ff - ], - // Whether the explosion has a trail. Optional, defaults to false. - "has_trail": true, - // Whether the explosion has a twinkle. Optional, defaults to false. - "has_twinkle": true - } - ], - // The flight duration of the fireworks. Optional, uses the existing data component value if absent. - "flight_duration": 5 + "function": "minecraft:set_fireworks", + // The explosions to use. Optional, uses the existing data component value if absent. + "explosions": [ + { + // The firework explosion shape to use. Valid vanilla values are "small_ball", "large_ball", + // "star", "creeper" and "burst". Optional, defaults to "small_ball". + "shape": "star", + // The colors to use. Optional, defaults to an empty list. + "colors": [ + 16711680, + 65280 + ], + // The fade colors to use. Optional, defaults to an empty list. + "fade_colors": [ + 65280, + 255 + ], + // Whether the explosion has a trail. Optional, defaults to false. + "has_trail": true, + // Whether the explosion has a twinkle. Optional, defaults to false. + "has_twinkle": true + } + ], + // The flight duration of the fireworks. Optional, uses the existing data component value if absent. + "flight_duration": 5 } ``` @@ -665,24 +665,24 @@ Sets a firework explosion on the result item stack. ```json5 { - "function": "minecraft:set_firework_explosion", - // The firework explosion shape to use. Valid vanilla values are "small_ball", "large_ball", - // "star", "creeper" and "burst". Optional, defaults to "small_ball". - "shape": "star", - // The colors to use. Optional, defaults to an empty list. - "colors": [ - 0xff0000, - 0x00ff00 - ] - // The fade colors to use. Optional, defaults to an empty list. - "fade_colors": [ - 0x00ff00, - 0x0000ff - ], - // Whether the explosion has a trail. Optional, defaults to false. - "has_trail": true, - // Whether the explosion has a twinkle. Optional, defaults to false. - "has_twinkle": true + "function": "minecraft:set_firework_explosion", + // The firework explosion shape to use. Valid vanilla values are "small_ball", "large_ball", + // "star", "creeper" and "burst". Optional, defaults to "small_ball". + "shape": "star", + // The colors to use. Optional, defaults to an empty list. + "colors": [ + 16711680, + 65280 + ], + // The fade colors to use. Optional, defaults to an empty list. + "fade_colors": [ + 65280, + 255 + ], + // Whether the explosion has a trail. Optional, defaults to false. + "has_trail": true, + // Whether the explosion has a twinkle. Optional, defaults to false. + "has_twinkle": true } ``` @@ -694,14 +694,14 @@ Sets a written book's non-page-specific content. ```json5 { - "function": "minecraft:set_book_cover", - // The book title. Optional, if absent, the book title remains unchanged. - "title": "Hello World!", - // The book author. Optional, if absent, the book author remains unchanged. - "author": "Steve", - // The book generation, i.e. how often it has been copied. Clamped between 0 and 3. - // Optional, if absent, the book generation remains unchanged. - "generation": 2 + "function": "minecraft:set_book_cover", + // The book title. Optional, if absent, the book title remains unchanged. + "title": "Hello World!", + // The book author. Optional, if absent, the book author remains unchanged. + "author": "Steve", + // The book generation, i.e. how often it has been copied. Clamped between 0 and 3. + // Optional, if absent, the book generation remains unchanged. + "generation": 2 } ``` @@ -713,25 +713,25 @@ Sets the pages of a written book. ```json5 { - "function": "minecraft:set_written_book_pages", - // The pages to set, as a list of strings. - "pages": [ - "Hello World!", - "Hello World on page 2!", - "Never Gonna Give You Up!" - ], - // The merging mode used. Valid values are: - // - "append": Appends the entries to any existing lore entries. - // - "insert": Inserts the entries at a certain position. The position is denoted as an additional field - // named "offset". "offset" is optional and defaults to 0. - // - "replace_all": Removes all previous entries and then appends the entries. - // - "replace_section": Removes a section of entries and then adds the entries at that position. - // The section removed is denoted through the "offset" and optional "size" fields. - // If "size" is omitted, the amount of lines in "lore" is used. - "mode": { - "type": "insert", - "offset": 0 - } + "function": "minecraft:set_written_book_pages", + // The pages to set, as a list of strings. + "pages": [ + "Hello World!", + "Hello World on page 2!", + "Never Gonna Give You Up!" + ], + // The merging mode used. Valid values are: + // - "append": Appends the entries to any existing lore entries. + // - "insert": Inserts the entries at a certain position. The position is denoted as an additional field + // named "offset". "offset" is optional and defaults to 0. + // - "replace_all": Removes all previous entries and then appends the entries. + // - "replace_section": Removes a section of entries and then adds the entries at that position. + // The section removed is denoted through the "offset" and optional "size" fields. + // If "size" is omitted, the amount of lines in "lore" is used. + "mode": { + "type": "insert", + "offset": 0 + } } ``` @@ -743,25 +743,25 @@ Sets the pages of a writable book (book and quill). ```json5 { - "function": "minecraft:set_writable_book_pages", - // The pages to set, as a list of strings. - "pages": [ - "Hello World!", - "Hello World on page 2!", - "Never Gonna Give You Up!" - ], - // The merging mode used. Valid values are: - // - "append": Appends the entries to any existing lore entries. - // - "insert": Inserts the entries at a certain position. The position is denoted as an additional field - // named "offset". "offset" is optional and defaults to 0. - // - "replace_all": Removes all previous entries and then appends the entries. - // - "replace_section": Removes a section of entries and then adds the entries at that position. - // The section removed is denoted through the "offset" and optional "size" fields. - // If "size" is omitted, the amount of lines in "lore" is used. - "mode": { - "type": "insert", - "offset": 0 - } + "function": "minecraft:set_writable_book_pages", + // The pages to set, as a list of strings. + "pages": [ + "Hello World!", + "Hello World on page 2!", + "Never Gonna Give You Up!" + ], + // The merging mode used. Valid values are: + // - "append": Appends the entries to any existing lore entries. + // - "insert": Inserts the entries at a certain position. The position is denoted as an additional field + // named "offset". "offset" is optional and defaults to 0. + // - "replace_all": Removes all previous entries and then appends the entries. + // - "replace_section": Removes a section of entries and then adds the entries at that position. + // The section removed is denoted through the "offset" and optional "size" fields. + // If "size" is omitted, the amount of lines in "lore" is used. + "mode": { + "type": "insert", + "offset": 0 + } } ``` @@ -773,9 +773,9 @@ Sets the custom model data of the result item stack. ```json5 { - "function": "minecraft:set_custom_model_data", - // The custom model data value to use. This can also be a number provider. - "value": 4 + "function": "minecraft:set_custom_model_data", + // The custom model data value to use. This can also be a number provider. + "value": 4 } ``` @@ -787,15 +787,15 @@ This function accepts an `ItemPredicate` that is checked against the `tool` loot ```json5 { - "function": "minecraft:filtered", - // The custom model data value to use. This can also be a number provider. - "item_filter": { - "items": [ - "minecraft:diamond_shovel" - ] - }, - // The other loot function to run, as either a loot modifier file or an in-line list of functions. - "modifier": "examplemod:example_modifier" + "function": "minecraft:filtered", + // The custom model data value to use. This can also be a number provider. + "item_filter": { + "items": [ + "minecraft:diamond_shovel" + ] + }, + // The other loot function to run, as either a loot modifier file or an in-line list of functions. + "modifier": "examplemod:example_modifier" } ``` @@ -811,9 +811,9 @@ This function references an item modifier and applies it to the result item stac ```json5 { - "function": "minecraft:reference", - // Refers to the item modifier file at data/examplemod/item_modifier/example_modifier.json. - "name": "examplemod:example_modifier" + "function": "minecraft:reference", + // Refers to the item modifier file at data/examplemod/item_modifier/example_modifier.json. + "name": "examplemod:example_modifier" } ``` @@ -825,17 +825,17 @@ This function runs other loot functions one after another. ```json5 { - "function": "minecraft:sequence", - // A list of functions to run. - "functions": [ - { - "function": "minecraft:set_count", - // ... - }, - { - "function": "minecraft:explosion_decay" - } - ], + "function": "minecraft:sequence", + // A list of functions to run. + "functions": [ + { + "function": "minecraft:set_count", + // ... + }, + { + "function": "minecraft:explosion_decay" + } + ], } ``` @@ -848,7 +848,7 @@ During datagen, call `SequenceFunction#of` with the other functions to construct [component]: ../../client/i18n.md#components [conditions]: lootconditions [custom]: custom.md#custom-loot-functions -[datacomponent]: ../../../items/datacomponents.mdx +[datacomponent]: ../../../items/datacomponents.md [entitytarget]: index.md#entity-targets [entry]: index.md#loot-entry [itemmodifiers]: https://minecraft.wiki/w/Item_modifier#JSON_format diff --git a/docs/resources/server/recipes/builtin.md b/docs/resources/server/recipes/builtin.md index 2a3460293..a3d9d91e5 100644 --- a/docs/resources/server/recipes/builtin.md +++ b/docs/resources/server/recipes/builtin.md @@ -12,25 +12,25 @@ Some of the most important recipes - such as the crafting table, sticks, or most ```json5 { - "type": "minecraft:crafting_shaped", - "category": "equipment", - "pattern": [ - "XXX", - " # ", - " # " - ], - "key": { - "#": { - "item": "minecraft:stick" + "type": "minecraft:crafting_shaped", + "category": "equipment", + "pattern": [ + "XXX", + " # ", + " # " + ], + "key": { + "#": { + "item": "minecraft:stick" + }, + "X": { + "item": "minecraft:iron_ingot" + } }, - "X": { - "item": "minecraft:iron_ingot" + "result": { + "count": 1, + "id": "minecraft:iron_pickaxe" } - }, - "result": { - "count": 1, - "id": "minecraft:iron_pickaxe" - } } ``` @@ -39,8 +39,8 @@ Let's digest this line for line: - `type`: This is the id of the shaped recipe serializer, `minecraft:crafting_shaped`. - `category`: This optional field defines the category in the crafting book. - `key` and `pattern`: Together, these define how the items must be put into the crafting grid. - - The pattern defines up to three lines of up to three-wide strings that define the shape. All lines must be the same length, i.e. the pattern must form a rectangular shape. Spaces can be used to denote slots that should stay empty. - - The key associates the characters used in the pattern with [ingredients][ingredient]. In the above example, all `X`s in the pattern must be iron ingots, and all `#`s must be sticks. + - The pattern defines up to three lines of up to three-wide strings that define the shape. All lines must be the same length, i.e. the pattern must form a rectangular shape. Spaces can be used to denote slots that should stay empty. + - The key associates the characters used in the pattern with [ingredients][ingredient]. In the above example, all `X`s in the pattern must be iron ingots, and all `#`s must be sticks. - `result`: The result of the recipe. This is [an item stack's JSON representation][itemjson]. - Not shown in the example is the `group` key. This optional string property creates a group in the recipe book. Recipes in the same group will be displayed as one in the recipe book. @@ -78,23 +78,23 @@ Unlike shaped crafting recipes, shapeless crafting recipes do not care about the ```json5 { - "type": "minecraft:crafting_shapeless", - "category": "misc", - "ingredients": [ - { - "item": "minecraft:brown_mushroom" - }, - { - "item": "minecraft:red_mushroom" - }, - { - "item": "minecraft:bowl" + "type": "minecraft:crafting_shapeless", + "category": "misc", + "ingredients": [ + { + "item": "minecraft:brown_mushroom" + }, + { + "item": "minecraft:red_mushroom" + }, + { + "item": "minecraft:bowl" + } + ], + "result": { + "count": 1, + "id": "minecraft:mushroom_stew" } - ], - "result": { - "count": 1, - "id": "minecraft:mushroom_stew" - } } ``` @@ -143,7 +143,7 @@ In some cases, outputs must be created dynamically from inputs. Most of the time ```java { - "type": "minecraft:crafting_special_armordye" + "type": "minecraft:crafting_special_armordye" } ``` @@ -182,16 +182,16 @@ The second most important group of recipes are the ones made through smelting or ```json5 { - "type": "minecraft:smelting", - "category": "food", - "cookingtime": 200, - "experience": 0.1, - "ingredient": { - "item": "minecraft:kelp" - }, - "result": { - "id": "minecraft:dried_kelp" - } + "type": "minecraft:smelting", + "category": "food", + "cookingtime": 200, + "experience": 0.1, + "ingredient": { + "item": "minecraft:kelp" + }, + "result": { + "id": "minecraft:dried_kelp" + } } ``` @@ -237,14 +237,14 @@ Stonecutter recipes use the `minecraft:stonecutting` recipe type. They are about ```json5 { - "type": "minecraft:stonecutting", - "ingredient": { - "item": "minecraft:andesite" - }, - "result": { - "count": 2, - "id": "minecraft:andesite_slab" - } + "type": "minecraft:stonecutting", + "ingredient": { + "item": "minecraft:andesite" + }, + "result": { + "count": 2, + "id": "minecraft:andesite_slab" + } } ``` @@ -270,20 +270,20 @@ This recipe serializer is for transforming two input items into one, preserving ```json5 { - "type": "minecraft:smithing_transform", - "base": { - "item": "minecraft:diamond_axe" - }, - "template": { - "item": "minecraft:netherite_upgrade_smithing_template" - }, - "addition": { - "item": "minecraft:netherite_ingot" - }, - "result": { - "count": 1, - "id": "minecraft:netherite_axe" - } + "type": "minecraft:smithing_transform", + "base": { + "item": "minecraft:diamond_axe" + }, + "template": { + "item": "minecraft:netherite_upgrade_smithing_template" + }, + "addition": { + "item": "minecraft:netherite_ingot" + }, + "result": { + "count": 1, + "id": "minecraft:netherite_axe" + } } ``` @@ -323,16 +323,16 @@ Trim smithing is the process of applying armor trims to armor: ```json5 { - "type": "minecraft:smithing_trim", - "addition": { - "tag": "minecraft:trim_materials" - }, - "base": { - "tag": "minecraft:trimmable_armor" - }, - "template": { - "item": "minecraft:bolt_armor_trim_smithing_template" - } + "type": "minecraft:smithing_trim", + "addition": { + "tag": "minecraft:trim_materials" + }, + "base": { + "tag": "minecraft:trimmable_armor" + }, + "template": { + "item": "minecraft:bolt_armor_trim_smithing_template" + } } ``` diff --git a/docs/resources/server/recipes/index.md b/docs/resources/server/recipes/index.md index 97322880f..90b5cd84b 100644 --- a/docs/resources/server/recipes/index.md +++ b/docs/resources/server/recipes/index.md @@ -23,10 +23,10 @@ The contents of recipe files vary greatly depending on the selected type. Common ```json5 { - // The recipe type. This maps to an entry in the recipe serializer registry. - "type": "minecraft:crafting_shaped", - // A list of data load conditions. Optional, NeoForge-added. See the article linked above for more information. - "neoforge:conditions": [ /*...*/ ] + // The recipe type. This maps to an entry in the recipe serializer registry. + "type": "minecraft:crafting_shaped", + // A list of data load conditions. Optional, NeoForge-added. See the article linked above for more information. + "neoforge:conditions": [ /*...*/ ] } ``` diff --git a/docs/resources/server/recipes/ingredients.md b/docs/resources/server/recipes/ingredients.md index 9792fcf6d..1679153a4 100644 --- a/docs/resources/server/recipes/ingredients.md +++ b/docs/resources/server/recipes/ingredients.md @@ -140,8 +140,8 @@ Ingredients that specify a `type` are generally assumed to be non-vanilla. For e ```json5 { - "type": "neoforge:block_tag", - "tag": "minecraft:convertable_to_mud" + "type": "neoforge:block_tag", + "tag": "minecraft:convertable_to_mud" } ``` @@ -149,11 +149,11 @@ Or another example using our own ingredient: ```json5 { - "type": "examplemod:min_enchanted", - "tag": "c:swords", - "enchantments": { - "minecraft:sharpness": 4 - } + "type": "examplemod:min_enchanted", + "tag": "c:swords", + "enchantments": { + "minecraft:sharpness": 4 + } } ``` @@ -163,7 +163,7 @@ An example for a vanilla item ingredient: ```json5 { - "item": "minecraft:dirt" + "item": "minecraft:dirt" } ``` @@ -171,7 +171,7 @@ An example for a vanilla tag ingredient: ```json5 { - "tag": "c:ingots" + "tag": "c:ingots" } ``` diff --git a/docs/resources/server/tags.md b/docs/resources/server/tags.md index 37e2e79c3..ff6f23914 100644 --- a/docs/resources/server/tags.md +++ b/docs/resources/server/tags.md @@ -20,30 +20,30 @@ Tag files have the following syntax: ```json5 { - // The values of the tag. - "values": [ - // A value object. Must specify the id of the object to add, and whether it is required. - // If the entry is required, but the object is not present, the tag will not load. The "required" field - // is technically optional, but when removed, the entry is equivalent to the shorthand below. - { - "id": "examplemod:example_ingot", - "required": false - } - // Shorthand for {"id": "minecraft:gold_ingot", "required": true}, i.e. a required entry. - "minecraft:gold_ingot", - // A tag object. Distinguished from regular entries by the leading #. In this case, all planks - // will be considered entries of the tag. Like normal entries, this can also have the "id"/"required" format. - // Warning: Circular tag dependencies will lead to a datapack not being loaded! - "#minecraft:planks" - ], - // Whether to remove all pre-existing entries before adding your own (true) or just add your own (false). - // This should generally be false, the option to set this to true is primarily aimed at pack developers. - "replace": false, - // A finer-grained way to remove entries from the tag again, if present. Optional, NeoForge-added. - // Entry syntax is the same as in the "values" array. - "remove": [ - "minecraft:iron_ingot" - ] + // The values of the tag. + "values": [ + // A value object. Must specify the id of the object to add, and whether it is required. + // If the entry is required, but the object is not present, the tag will not load. The "required" field + // is technically optional, but when removed, the entry is equivalent to the shorthand below. + { + "id": "examplemod:example_ingot", + "required": false + } + // Shorthand for {"id": "minecraft:gold_ingot", "required": true}, i.e. a required entry. + "minecraft:gold_ingot", + // A tag object. Distinguished from regular entries by the leading #. In this case, all planks + // will be considered entries of the tag. Like normal entries, this can also have the "id"/"required" format. + // Warning: Circular tag dependencies will lead to a datapack not being loaded! + "#minecraft:planks" + ], + // Whether to remove all pre-existing entries before adding your own (true) or just add your own (false). + // This should generally be false, the option to set this to true is primarily aimed at pack developers. + "replace": false, + // A finer-grained way to remove entries from the tag again, if present. Optional, NeoForge-added. + // Entry syntax is the same as in the "values" array. + "remove": [ + "minecraft:iron_ingot" + ] } ``` @@ -202,33 +202,33 @@ This example results in the following tag JSON: ```json5 { - "values": [ - "minecraft:dirt", - "minecraft:cobblestone", - { - "id": "botania:pure_daisy", - "required": false - }, - "#minecraft:planks", - "#minecraft:logs", - "#minecraft:wooden_slabs", - { - "id": "c:ingots/tin", - "required": false - }, - { - "id": "c:nuggets/tin", - "required": false - }, - { - "id": "c:storage_blocks/tin", - "required": false - } - ], - "remove": [ - "minecraft:crimson_slab", - "minecraft:warped_slab" - ] + "values": [ + "minecraft:dirt", + "minecraft:cobblestone", + { + "id": "botania:pure_daisy", + "required": false + }, + "#minecraft:planks", + "#minecraft:logs", + "#minecraft:wooden_slabs", + { + "id": "c:ingots/tin", + "required": false + }, + { + "id": "c:nuggets/tin", + "required": false + }, + { + "id": "c:storage_blocks/tin", + "required": false + } + ], + "remove": [ + "minecraft:crimson_slab", + "minecraft:warped_slab" + ] } ``` diff --git a/docs/worldgen/_category_.json b/docs/worldgen/_category_.json index 7b025865e..019b3d56f 100644 --- a/docs/worldgen/_category_.json +++ b/docs/worldgen/_category_.json @@ -1,4 +1,4 @@ { - "label": "Worldgen", - "position": 10 + "label": "Worldgen", + "position": 10 } \ No newline at end of file diff --git a/docs/worldgen/biomemodifier.md b/docs/worldgen/biomemodifier.md index ba9102227..78757c17e 100644 --- a/docs/worldgen/biomemodifier.md +++ b/docs/worldgen/biomemodifier.md @@ -8,20 +8,20 @@ Biome Modifiers are a data-driven system that allows for changing many aspects o ### Recommended Section To Read: - Players or pack developers: - - [Applying Biome Modifiers](#applying-biome-modifiers) - - [Built-in Neoforge Biome Modifiers](#built-in-biome-modifiers) + - [Applying Biome Modifiers](#applying-biome-modifiers) + - [Built-in Neoforge Biome Modifiers](#built-in-biome-modifiers) - Modders doing simple additions or removal biome modifications: - - [Applying Biome Modifiers](#applying-biome-modifiers) - - [Built-in Neoforge Biome Modifiers](#built-in-biome-modifiers) - - [Datagenning Biome Modifiers](#datagenning-biome-modifiers) + - [Applying Biome Modifiers](#applying-biome-modifiers) + - [Built-in Neoforge Biome Modifiers](#built-in-biome-modifiers) + - [Datagenning Biome Modifiers](#datagenning-biome-modifiers) - Modders who want to do custom or complex biome modifications: - - [Applying Biome Modifiers](#applying-biome-modifiers) - - [Creating Custom Biome Modifiers](#creating-custom-biome-modifiers) - - [Datagenning Biome Modifiers](#datagenning-biome-modifiers) + - [Applying Biome Modifiers](#applying-biome-modifiers) + - [Creating Custom Biome Modifiers](#creating-custom-biome-modifiers) + - [Datagenning Biome Modifiers](#datagenning-biome-modifiers) ## Applying Biome Modifiers @@ -39,16 +39,16 @@ These biome modifiers are registered by NeoForge for anyone to use. This biome modifier has no operation and will do no modification. Pack makers and players can use this in a datapack to disable mods' biome modifiers by overriding their biome modifier JSONs with the JSON below. - + ```json5 { - "type": "neoforge:none" + "type": "neoforge:none" } ``` - - + + ```java // Define the ResourceKey for our BiomeModifier. @@ -65,7 +65,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + ### Add Features @@ -73,27 +73,27 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { This biome modifier type adds `PlacedFeature`s (such as trees or ores) to biomes so that they can spawn during world generation. The modifier takes in the biome id or tag of the biomes the features are added to, a `PlacedFeature` id or tag to add to the selected biomes, and the [`GenerationStep.Decoration`](#Available-Values-for-Decoration-Steps) the features will be generated within. - + ```json5 { - "type": "neoforge:add_features", - // Can either be a biome id, such as "minecraft:plains", - // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], - // or a biome tag, such as "#c:is_overworld". - "biomes": "#namespace:your_biome_tag", - // Can either be a placed feature id, such as "examplemod:add_features_example", - // or a list of placed feature ids, such as ["examplemod:add_features_example", minecraft:ice_spike", ...], - // or a placed feature tag, such as "#examplemod:placed_feature_tag". - "features": "namespace:your_feature", - // See the GenerationStep.Decoration enum in code for a list of valid enum names. - // The decoration step section further down also has the list of values for reference. - "step": "underground_ores" + "type": "neoforge:add_features", + // Can either be a biome id, such as "minecraft:plains", + // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], + // or a biome tag, such as "#c:is_overworld". + "biomes": "#namespace:your_biome_tag", + // Can either be a placed feature id, such as "examplemod:add_features_example", + // or a list of placed feature ids, such as ["examplemod:add_features_example", minecraft:ice_spike", ...], + // or a placed feature tag, such as "#examplemod:placed_feature_tag". + "features": "namespace:your_feature", + // See the GenerationStep.Decoration enum in code for a list of valid enum names. + // The decoration step section further down also has the list of values for reference. + "step": "underground_ores" } ``` - - + + ```java // Assume we have some PlacedFeature named EXAMPLE_PLACED_FEATURE. @@ -125,7 +125,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }) ``` - + @@ -140,7 +140,7 @@ Vanilla `PlacedFeature`s can be referenced in biome JSONs or added via biome mod This biome modifier type removes features (such as trees or ores) from biomes so that they will no longer spawn during world generation. The modifier takes in the biome id or tag of the biomes the features are removed from, a `PlacedFeature` id or tag to remove from the selected biomes, and the [`GenerationStep.Decoration`](#Available-Values-for-Decoration-Steps)s that the features will be removed from. - + ```json5 { @@ -161,8 +161,8 @@ This biome modifier type removes features (such as trees or ores) from biomes so } ``` - - + + ```java // Define the ResourceKey for our BiomeModifier. @@ -196,7 +196,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + @@ -209,35 +209,35 @@ If you are a modder adding a new entity, make sure the entity has a spawn restri ::: - + ```json5 { - "type": "neoforge:add_spawns", - // Can either be a biome id, such as "minecraft:plains", - // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], - // or a biome tag, such as "#c:is_overworld". - "biomes": "#namespace:biome_tag", - // Can be either a single object or a list of objects. - "spawners": [ - { - "type": "namespace:entity_type", // The id of the entity type to spawn - "weight": 100, // int, spawn weight - "minCount": 1, // int, minimum group size - "maxCount": 4 // int, maximum group size - }, - { - "type": "minecraft:ghast", - "weight": 1, - "minCount": 5, - "maxCount": 10 - } - ] + "type": "neoforge:add_spawns", + // Can either be a biome id, such as "minecraft:plains", + // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], + // or a biome tag, such as "#c:is_overworld". + "biomes": "#namespace:biome_tag", + // Can be either a single object or a list of objects. + "spawners": [ + { + "type": "namespace:entity_type", // The id of the entity type to spawn + "weight": 100, // int, spawn weight + "minCount": 1, // int, minimum group size + "maxCount": 4 // int, maximum group size + }, + { + "type": "minecraft:ghast", + "weight": 1, + "minCount": 5, + "maxCount": 10 + } + ] } ``` - - + + ```java // Assume we have some EntityType named EXAMPLE_ENTITY. @@ -269,7 +269,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + @@ -278,24 +278,24 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { This biome modifier type removes entity spawns from biomes. The modifier takes in the biome id or tag of the biomes the entity spawns are removed from, and the `EntityType` id or tag of the entities to remove. - + ```json5 { - "type": "neoforge:remove_spawns", - // Can either be a biome id, such as "minecraft:plains", - // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], - // or a biome tag, such as "#c:is_overworld". - "biomes": "#namespace:biome_tag", - // Can either be an entity type id, such as "minecraft:ghast", - // or a list of entity type ids, such as ["minecraft:ghast", "minecraft:skeleton", ...], - // or an entity type tag, such as "#minecraft:skeletons". - "entity_types": "#namespace:entitytype_tag" + "type": "neoforge:remove_spawns", + // Can either be a biome id, such as "minecraft:plains", + // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], + // or a biome tag, such as "#c:is_overworld". + "biomes": "#namespace:biome_tag", + // Can either be an entity type id, such as "minecraft:ghast", + // or a list of entity type ids, such as ["minecraft:ghast", "minecraft:skeleton", ...], + // or an entity type tag, such as "#minecraft:skeletons". + "entity_types": "#namespace:entitytype_tag" } ``` - - + + ```java // Define the ResourceKey for our BiomeModifier. @@ -324,7 +324,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + @@ -339,30 +339,30 @@ If you are a modder adding a new entity, make sure the entity has a spawn restri ::: - + ```json5 { - "type": "neoforge:add_spawn_costs", - // Can either be a biome id, such as "minecraft:plains", - // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], - // or a biome tag, such as "#c:is_overworld". - "biomes": "#namespace:biome_tag", - // Can either be an entity type id, such as "minecraft:ghast", - // or a list of entity type ids, such as ["minecraft:ghast", "minecraft:skeleton", ...], - // or an entity type tag, such as "#minecraft:skeletons". - "entity_types": "#minecraft:skeletons", - "spawn_cost": { - // The energy budget - "energy_budget": 1.0, - // The amount of charge each entity takes up from the budget - "charge": 0.1 - } + "type": "neoforge:add_spawn_costs", + // Can either be a biome id, such as "minecraft:plains", + // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], + // or a biome tag, such as "#c:is_overworld". + "biomes": "#namespace:biome_tag", + // Can either be an entity type id, such as "minecraft:ghast", + // or a list of entity type ids, such as ["minecraft:ghast", "minecraft:skeleton", ...], + // or an entity type tag, such as "#minecraft:skeletons". + "entity_types": "#minecraft:skeletons", + "spawn_cost": { + // The energy budget + "energy_budget": 1.0, + // The amount of charge each entity takes up from the budget + "charge": 0.1 + } } ``` - - + + ```java // Define the ResourceKey for our BiomeModifier. @@ -395,7 +395,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + @@ -404,24 +404,24 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { Allows for removing a spawn cost from a biome. Spawn costs are a newer way of making mobs spawn spread out in a biome to reduce clustering. The modifier takes in the biome id or tag of the biomes the spawn costs are removed from, and the `EntityType` id or tag of the entities to remove the spawn cost for. - + ```json5 { - "type": "neoforge:remove_spawn_costs", - // Can either be a biome id, such as "minecraft:plains", - // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], - // or a biome tag, such as "#c:is_overworld". - "biomes": "#namespace:biome_tag", - // Can either be an entity type id, such as "minecraft:ghast", - // or a list of entity type ids, such as ["minecraft:ghast", "minecraft:skeleton", ...], - // or an entity type tag, such as "#minecraft:skeletons". - "entity_types": "#minecraft:skeletons" + "type": "neoforge:remove_spawn_costs", + // Can either be a biome id, such as "minecraft:plains", + // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], + // or a biome tag, such as "#c:is_overworld". + "biomes": "#namespace:biome_tag", + // Can either be an entity type id, such as "minecraft:ghast", + // or a list of entity type ids, such as ["minecraft:ghast", "minecraft:skeleton", ...], + // or an entity type tag, such as "#minecraft:skeletons". + "entity_types": "#minecraft:skeletons" } ``` - - + + ```java // Define the ResourceKey for our BiomeModifier. @@ -450,7 +450,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + @@ -459,27 +459,27 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { This biome modifier type allows adding carver caves and ravines to biomes. These are what was used for cave generation before the Caves and Cliffs update. It CANNOT add noise caves to biomes, because noise caves are a part of certain noise-based chunk generator systems and not actually tied to biomes. - + ```json5 -{ - "type": "neoforge:add_carvers", - // Can either be a biome id, such as "minecraft:plains", - // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], - // or a biome tag, such as "#c:is_overworld". - "biomes": "minecraft:plains", - // Can either be a carver id, such as "examplemod:add_carvers_example", - // or a list of carver ids, such as ["examplemod:add_carvers_example", "minecraft:canyon", ...], - // or a carver tag, such as "#examplemod:configured_carver_tag". - "carvers": "examplemod:add_carvers_example", - // See GenerationStep.Carving in code for a list of valid enum names. - // Only "air" and "liquid" are available. - "step": "air" + { + "type": "neoforge:add_carvers", + // Can either be a biome id, such as "minecraft:plains", + // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], + // or a biome tag, such as "#c:is_overworld". + "biomes": "minecraft:plains", + // Can either be a carver id, such as "examplemod:add_carvers_example", + // or a list of carver ids, such as ["examplemod:add_carvers_example", "minecraft:canyon", ...], + // or a carver tag, such as "#examplemod:configured_carver_tag". + "carvers": "examplemod:add_carvers_example", + // See GenerationStep.Carving in code for a list of valid enum names. + // Only "air" and "liquid" are available. + "step": "air" } ``` - - + + ```java // Assume we have some ConfiguredWorldCarver named EXAMPLE_CARVER. @@ -511,7 +511,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + ### Removing Legacy Carvers @@ -519,32 +519,32 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { This biome modifier type allows removing carver caves and ravines from biomes. These are what was used for cave generation before the Caves and Cliffs update. It CANNOT remove noise caves from biomes, because noise caves are baked into the dimension's noise settings system and not actually tied to biomes. - + ```json5 { - "type": "neoforge:remove_carvers", - // Can either be a biome id, such as "minecraft:plains", - // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], - // or a biome tag, such as "#c:is_overworld". - "biomes": "minecraft:plains", - // Can either be a carver id, such as "examplemod:add_carvers_example", - // or a list of carver ids, such as ["examplemod:add_carvers_example", "minecraft:canyon", ...], - // or a carver tag, such as "#examplemod:configured_carver_tag". - "carvers": "examplemod:add_carvers_example", - // Can either be a single generation step, such as "air", - // or a list of generation steps, such as ["air", "liquid"]. - // See GenerationStep.Carving for a list of valid enum names. - // Only "air" and "liquid" are available. - "steps": [ - "air", - "liquid" - ] + "type": "neoforge:remove_carvers", + // Can either be a biome id, such as "minecraft:plains", + // or a list of biome ids, such as ["minecraft:plains", "minecraft:badlands", ...], + // or a biome tag, such as "#c:is_overworld". + "biomes": "minecraft:plains", + // Can either be a carver id, such as "examplemod:add_carvers_example", + // or a list of carver ids, such as ["examplemod:add_carvers_example", "minecraft:canyon", ...], + // or a carver tag, such as "#examplemod:configured_carver_tag". + "carvers": "examplemod:add_carvers_example", + // Can either be a single generation step, such as "air", + // or a list of generation steps, such as ["air", "liquid"]. + // See GenerationStep.Carving for a list of valid enum names. + // Only "air" and "liquid" are available. + "steps": [ + "air", + "liquid" + ] } ``` - - + + ```java // Define the ResourceKey for our BiomeModifier. @@ -578,7 +578,7 @@ BUILDER.add(NeoForgeRegistries.Keys.BIOME_MODIFIERS, bootstrap -> { }); ``` - + ### Available Values for Decoration Steps diff --git a/neogradle/docs/configuration/index.mdx b/neogradle/docs/configuration/index.md similarity index 100% rename from neogradle/docs/configuration/index.mdx rename to neogradle/docs/configuration/index.md diff --git a/neogradle_versions.json b/neogradle_versions.json index 3f6328c12..441cb05ab 100644 --- a/neogradle_versions.json +++ b/neogradle_versions.json @@ -1,4 +1,4 @@ [ - "6.x", - "5.x" + "6.x", + "5.x" ] diff --git a/src/pages/contributing.mdx b/src/pages/contributing.md similarity index 99% rename from src/pages/contributing.mdx rename to src/pages/contributing.md index 04f4c8e07..878cc8814 100644 --- a/src/pages/contributing.mdx +++ b/src/pages/contributing.md @@ -61,8 +61,6 @@ If the pseudocode is not explanatory enough to understand the concept, then a fu If a change occurs between a minor or patch versions of NeoForge, then relevant changes in the documentation should be split into separate sections or put into tabs. This maintains the accuracy of the information depending on the version the modder is currently developing for. -Tabs must be in an `.mdx` file, not an `.md` file, for proper IDE support. - ````md import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; diff --git a/src/pages/index.md b/src/pages/index.md new file mode 100644 index 000000000..362152449 --- /dev/null +++ b/src/pages/index.md @@ -0,0 +1,33 @@ +import Card from "../theme/Card.tsx"; + +# NeoForged Documentation + +This is the official documentation for [NeoForged], the Minecraft modding API. + +This documentation is _only_ for NeoForged, **this is not a Java tutorial**. + +If you would like to contribute to the docs, read [Contributing to the Docs][contributing]. + +
+
+
+ +
+
+ +
+
+
+ +[NeoForged]: https://neoforged.net +[contributing]: ./contributing diff --git a/src/pages/index.mdx b/src/pages/index.mdx deleted file mode 100644 index e69872017..000000000 --- a/src/pages/index.mdx +++ /dev/null @@ -1,33 +0,0 @@ -import Card from "../theme/Card.tsx"; - -# NeoForged Documentation - -This is the official documentation for [NeoForged], the Minecraft modding API. - -This documentation is _only_ for NeoForged, **this is not a Java tutorial**. - -If you would like to contribute to the docs, read [Contributing to the Docs][contributing]. - -
-
-
- -
-
- -
-
-
- -[NeoForged]: https://neoforged.net -[contributing]: ./contributing From 3d8884d277c03efbb226474db970b66720ee03f1 Mon Sep 17 00:00:00 2001 From: ChampionAsh5357 Date: Mon, 14 Oct 2024 01:15:17 -0400 Subject: [PATCH 02/44] chore(docs): Move old version to 1.21.1 subdirectory --- .../version-1.21.1/advanced/_category_.json | 4 + .../advanced/accesstransformers.md | 147 +++ .../advanced/extensibleenums.md | 149 +++ .../blockentities/_category_.json | 4 + .../version-1.21.1/blockentities/ber.md | 123 +++ .../version-1.21.1/blockentities/container.md | 312 +++++++ .../version-1.21.1/blockentities/index.md | 240 +++++ .../version-1.21.1/blocks/_category_.json | 4 + versioned_docs/version-1.21.1/blocks/index.md | 313 +++++++ .../version-1.21.1/blocks/states.md | 148 +++ .../version-1.21.1/concepts/_category_.json | 4 + .../version-1.21.1/concepts/events.md | 200 ++++ .../version-1.21.1/concepts/registries.md | 319 +++++++ .../version-1.21.1/concepts/sides.md | 89 ++ .../datastorage/_category_.json | 4 + .../version-1.21.1/datastorage/attachments.md | 118 +++ .../datastorage/capabilities.md | 340 +++++++ .../version-1.21.1/datastorage/codecs.md | 593 ++++++++++++ .../version-1.21.1/datastorage/nbt.md | 105 +++ .../version-1.21.1/datastorage/saveddata.md | 43 + .../gettingstarted/_category_.json | 4 + .../version-1.21.1/gettingstarted/index.md | 61 ++ .../version-1.21.1/gettingstarted/modfiles.md | 245 +++++ .../gettingstarted/structuring.md | 80 ++ .../gettingstarted/versioning.md | 96 ++ .../version-1.21.1/gui/_category_.json | 4 + versioned_docs/version-1.21.1/gui/menus.md | 348 +++++++ versioned_docs/version-1.21.1/gui/screens.md | 413 +++++++++ .../version-1.21.1/items/_category_.json | 4 + .../version-1.21.1/items/datacomponents.md | 391 ++++++++ versioned_docs/version-1.21.1/items/index.md | 240 +++++ .../items/interactionpipeline.md | 73 ++ .../version-1.21.1/items/mobeffects.md | 199 ++++ versioned_docs/version-1.21.1/items/tools.md | 240 +++++ .../version-1.21.1/legacy/_category_.json | 4 + .../version-1.21.1/legacy/porting.md | 25 + .../version-1.21.1/misc/_category_.json | 4 + versioned_docs/version-1.21.1/misc/config.md | 208 +++++ .../version-1.21.1/misc/debugprofiler.md | 50 + .../version-1.21.1/misc/gametest.md | 282 ++++++ .../version-1.21.1/misc/keymappings.md | 154 ++++ .../version-1.21.1/misc/resourcelocation.md | 48 + .../version-1.21.1/misc/updatechecker.md | 59 ++ .../version-1.21.1/networking/_category_.json | 4 + .../networking/configuration-tasks.md | 133 +++ .../version-1.21.1/networking/entities.md | 30 + .../version-1.21.1/networking/index.md | 17 + .../version-1.21.1/networking/payload.md | 193 ++++ .../version-1.21.1/networking/streamcodecs.md | 386 ++++++++ .../version-1.21.1/resources/_category_.json | 4 + .../resources/client/_category_.json | 3 + .../version-1.21.1/resources/client/i18n.md | 189 ++++ .../resources/client/models/bakedmodel.md | 137 +++ .../resources/client/models/datagen.md | 283 ++++++ .../resources/client/models/index.md | 326 +++++++ .../resources/client/models/modelloaders.md | 468 ++++++++++ .../resources/client/particles.md | 249 +++++ .../version-1.21.1/resources/client/sounds.md | 313 +++++++ .../resources/client/textures.md | 70 ++ .../version-1.21.1/resources/index.md | 218 +++++ .../resources/server/_category_.json | 3 + .../resources/server/advancements.md | 282 ++++++ .../resources/server/conditions.md | 202 ++++ .../resources/server/damagetypes.md | 133 +++ .../resources/server/datamaps/builtin.md | 228 +++++ .../resources/server/datamaps/index.md | 390 ++++++++ .../resources/server/enchantments/builtin.md | 341 +++++++ .../resources/server/enchantments/index.md | 325 +++++++ .../resources/server/loottables/custom.md | 297 ++++++ .../resources/server/loottables/glm.md | 191 ++++ .../resources/server/loottables/index.md | 428 +++++++++ .../server/loottables/lootconditions.md | 400 ++++++++ .../server/loottables/lootfunctions.md | 859 ++++++++++++++++++ .../resources/server/recipes/builtin.md | 368 ++++++++ .../resources/server/recipes/index.md | 534 +++++++++++ .../resources/server/recipes/ingredients.md | 184 ++++ .../version-1.21.1/resources/server/tags.md | 305 +++++++ .../version-1.21.1/worldgen/_category_.json | 4 + .../version-1.21.1/worldgen/biomemodifier.md | 702 ++++++++++++++ versions.json | 5 +- 80 files changed, 15693 insertions(+), 2 deletions(-) create mode 100644 versioned_docs/version-1.21.1/advanced/_category_.json create mode 100644 versioned_docs/version-1.21.1/advanced/accesstransformers.md create mode 100644 versioned_docs/version-1.21.1/advanced/extensibleenums.md create mode 100644 versioned_docs/version-1.21.1/blockentities/_category_.json create mode 100644 versioned_docs/version-1.21.1/blockentities/ber.md create mode 100644 versioned_docs/version-1.21.1/blockentities/container.md create mode 100644 versioned_docs/version-1.21.1/blockentities/index.md create mode 100644 versioned_docs/version-1.21.1/blocks/_category_.json create mode 100644 versioned_docs/version-1.21.1/blocks/index.md create mode 100644 versioned_docs/version-1.21.1/blocks/states.md create mode 100644 versioned_docs/version-1.21.1/concepts/_category_.json create mode 100644 versioned_docs/version-1.21.1/concepts/events.md create mode 100644 versioned_docs/version-1.21.1/concepts/registries.md create mode 100644 versioned_docs/version-1.21.1/concepts/sides.md create mode 100644 versioned_docs/version-1.21.1/datastorage/_category_.json create mode 100644 versioned_docs/version-1.21.1/datastorage/attachments.md create mode 100644 versioned_docs/version-1.21.1/datastorage/capabilities.md create mode 100644 versioned_docs/version-1.21.1/datastorage/codecs.md create mode 100644 versioned_docs/version-1.21.1/datastorage/nbt.md create mode 100644 versioned_docs/version-1.21.1/datastorage/saveddata.md create mode 100644 versioned_docs/version-1.21.1/gettingstarted/_category_.json create mode 100644 versioned_docs/version-1.21.1/gettingstarted/index.md create mode 100644 versioned_docs/version-1.21.1/gettingstarted/modfiles.md create mode 100644 versioned_docs/version-1.21.1/gettingstarted/structuring.md create mode 100644 versioned_docs/version-1.21.1/gettingstarted/versioning.md create mode 100644 versioned_docs/version-1.21.1/gui/_category_.json create mode 100644 versioned_docs/version-1.21.1/gui/menus.md create mode 100644 versioned_docs/version-1.21.1/gui/screens.md create mode 100644 versioned_docs/version-1.21.1/items/_category_.json create mode 100644 versioned_docs/version-1.21.1/items/datacomponents.md create mode 100644 versioned_docs/version-1.21.1/items/index.md create mode 100644 versioned_docs/version-1.21.1/items/interactionpipeline.md create mode 100644 versioned_docs/version-1.21.1/items/mobeffects.md create mode 100644 versioned_docs/version-1.21.1/items/tools.md create mode 100644 versioned_docs/version-1.21.1/legacy/_category_.json create mode 100644 versioned_docs/version-1.21.1/legacy/porting.md create mode 100644 versioned_docs/version-1.21.1/misc/_category_.json create mode 100644 versioned_docs/version-1.21.1/misc/config.md create mode 100644 versioned_docs/version-1.21.1/misc/debugprofiler.md create mode 100644 versioned_docs/version-1.21.1/misc/gametest.md create mode 100644 versioned_docs/version-1.21.1/misc/keymappings.md create mode 100644 versioned_docs/version-1.21.1/misc/resourcelocation.md create mode 100644 versioned_docs/version-1.21.1/misc/updatechecker.md create mode 100644 versioned_docs/version-1.21.1/networking/_category_.json create mode 100644 versioned_docs/version-1.21.1/networking/configuration-tasks.md create mode 100644 versioned_docs/version-1.21.1/networking/entities.md create mode 100644 versioned_docs/version-1.21.1/networking/index.md create mode 100644 versioned_docs/version-1.21.1/networking/payload.md create mode 100644 versioned_docs/version-1.21.1/networking/streamcodecs.md create mode 100644 versioned_docs/version-1.21.1/resources/_category_.json create mode 100644 versioned_docs/version-1.21.1/resources/client/_category_.json create mode 100644 versioned_docs/version-1.21.1/resources/client/i18n.md create mode 100644 versioned_docs/version-1.21.1/resources/client/models/bakedmodel.md create mode 100644 versioned_docs/version-1.21.1/resources/client/models/datagen.md create mode 100644 versioned_docs/version-1.21.1/resources/client/models/index.md create mode 100644 versioned_docs/version-1.21.1/resources/client/models/modelloaders.md create mode 100644 versioned_docs/version-1.21.1/resources/client/particles.md create mode 100644 versioned_docs/version-1.21.1/resources/client/sounds.md create mode 100644 versioned_docs/version-1.21.1/resources/client/textures.md create mode 100644 versioned_docs/version-1.21.1/resources/index.md create mode 100644 versioned_docs/version-1.21.1/resources/server/_category_.json create mode 100644 versioned_docs/version-1.21.1/resources/server/advancements.md create mode 100644 versioned_docs/version-1.21.1/resources/server/conditions.md create mode 100644 versioned_docs/version-1.21.1/resources/server/damagetypes.md create mode 100644 versioned_docs/version-1.21.1/resources/server/datamaps/builtin.md create mode 100644 versioned_docs/version-1.21.1/resources/server/datamaps/index.md create mode 100644 versioned_docs/version-1.21.1/resources/server/enchantments/builtin.md create mode 100644 versioned_docs/version-1.21.1/resources/server/enchantments/index.md create mode 100644 versioned_docs/version-1.21.1/resources/server/loottables/custom.md create mode 100644 versioned_docs/version-1.21.1/resources/server/loottables/glm.md create mode 100644 versioned_docs/version-1.21.1/resources/server/loottables/index.md create mode 100644 versioned_docs/version-1.21.1/resources/server/loottables/lootconditions.md create mode 100644 versioned_docs/version-1.21.1/resources/server/loottables/lootfunctions.md create mode 100644 versioned_docs/version-1.21.1/resources/server/recipes/builtin.md create mode 100644 versioned_docs/version-1.21.1/resources/server/recipes/index.md create mode 100644 versioned_docs/version-1.21.1/resources/server/recipes/ingredients.md create mode 100644 versioned_docs/version-1.21.1/resources/server/tags.md create mode 100644 versioned_docs/version-1.21.1/worldgen/_category_.json create mode 100644 versioned_docs/version-1.21.1/worldgen/biomemodifier.md diff --git a/versioned_docs/version-1.21.1/advanced/_category_.json b/versioned_docs/version-1.21.1/advanced/_category_.json new file mode 100644 index 000000000..2161114e5 --- /dev/null +++ b/versioned_docs/version-1.21.1/advanced/_category_.json @@ -0,0 +1,4 @@ +{ + "label": "Advanced Topics", + "position": 12 +} \ No newline at end of file diff --git a/versioned_docs/version-1.21.1/advanced/accesstransformers.md b/versioned_docs/version-1.21.1/advanced/accesstransformers.md new file mode 100644 index 000000000..f7399e76b --- /dev/null +++ b/versioned_docs/version-1.21.1/advanced/accesstransformers.md @@ -0,0 +1,147 @@ +# Access Transformers + +Access Transformers (ATs for short) allow for widening the visibility and modifying the `final` flags of classes, methods, and fields. They allow modders to access and modify otherwise inaccessible members in classes outside their control. + +The [specification document][specs] can be viewed on the NeoForged GitHub. + +## Adding ATs + +Adding an Access Transformer to your mod project is as simple as adding a single line into your `build.gradle`: + +Access Transformers need to be declared in `build.gradle`. AT files can be specified anywhere as long as they are copied to the `resources` output directory on compilation. + +```groovy +// In build.gradle: +// This block is where your mappings version is also specified +minecraft { + accessTransformers { + file('src/main/resources/META-INF/accesstransformer.cfg') + } +} +``` + +By default, NeoForge will search for `META-INF/accesstransformer.cfg`. If the `build.gradle` specifies access transformers in any other location, then their location needs to be defined within `neoforge.mods.toml`: + +```toml +# In neoforge.mods.toml: +[[accessTransformers]] +## The file is relative to the output directory of the resources, or the root path inside the jar when compiled +## The 'resources' directory represents the root output directory of the resources +file="META-INF/accesstransformer.cfg" +``` + +Additionally, multiple AT files can be specified and will be applied in order. This can be useful for larger mods with multiple packages. + +```groovy +// In build.gradle: +minecraft { + accessTransformers { + file('src/main/resources/accesstransformer_main.cfg') + file('src/additions/resources/accesstransformer_additions.cfg') + } +} +``` + +```toml +# In neoforge.mods.toml +[[accessTransformers]] +file="accesstransformer_main.cfg" + +[[accessTransformers]] +file="accesstransformer_additions.cfg" +``` + +After adding or modifying any Access Transformer, the Gradle project must be refreshed for the transformations to take effect. + +## The Access Transformer Specification + +### Comments + +All text after a `#` until the end of the line will be treated as a comment and will not be parsed. + +### Access Modifiers + +Access modifiers specify to what new member visibility the given target will be transformed to. In decreasing order of visibility: + +- `public` - visible to all classes inside and outside its package +- `protected` - visible only to classes inside the package and subclasses +- `default` - visible only to classes inside the package +- `private` - visible only to inside the class + +A special modifier `+f` and `-f` can be appended to the aforementioned modifiers to either add or remove respectively the `final` modifier, which prevents subclassing, method overriding, or field modification when applied. + +:::danger +Directives only modify the method they directly reference; any overriding methods will not be access-transformed. It is advised to ensure transformed methods do not have non-transformed overrides that restrict the visibility, which will result in the JVM throwing an error. + +Examples of methods that can be safely transformed are `private` methods, `final` methods (or methods in `final` classes), and `static` methods. +::: + +### Targets and Directives + +#### Classes + +To target classes: + +``` + +``` + +Inner classes are denoted by combining the fully qualified name of the outer class and the name of the inner class with a `$` as separator. + +#### Fields + +To target fields: + +``` + +``` + +#### Methods + +Targeting methods require a special syntax to denote the method parameters and return type: + +``` + () +``` + +##### Specifying Types + +Also called "descriptors": see the [Java Virtual Machine Specification, SE 21, sections 4.3.2 and 4.3.3][jvmdescriptors] for more technical details. + +- `B` - `byte`, a signed byte +- `C` - `char`, a Unicode character code point in UTF-16 +- `D` - `double`, a double-precision floating-point value +- `F` - `float`, a single-precision floating-point value +- `I` - `integer`, a 32-bit integer +- `J` - `long`, a 64-bit integer +- `S` - `short`, a signed short +- `Z` - `boolean`, a `true` or `false` value +- `[` - references one dimension of an array + - Example: `[[S` refers to `short[][]` +- `L;` - references a reference type + - Example: `Ljava/lang/String;` refers to `java.lang.String` reference type _(note the use of slashes instead of periods)_ +- `(` - references a method descriptor, parameters should be supplied here or nothing if no parameters are present + - Example: `(I)Z` refers to a method that requires an integer argument and returns a boolean +- `V` - indicates a method returns no value, can only be used at the end of a method descriptor + - Example: `()V` refers to a method that has no arguments and returns nothing + +### Examples + +``` +# Makes public the ByteArrayToKeyFunction interface in Crypt +public net.minecraft.util.Crypt$ByteArrayToKeyFunction + +# Makes protected and removes the final modifier from 'random' in MinecraftServer +protected-f net.minecraft.server.MinecraftServer random + +# Makes public the 'makeExecutor' method in Util, +# accepting a String and returns an ExecutorService +public net.minecraft.Util makeExecutor(Ljava/lang/String;)Ljava/util/concurrent/ExecutorService; + +# Makes public the 'leastMostToIntArray' method in UUIDUtil, +# accepting two longs and returning an int[] +public net.minecraft.core.UUIDUtil leastMostToIntArray(JJ)[I +``` + +[specs]: https://github.com/NeoForged/AccessTransformers/blob/main/FMLAT.md +[jvmdescriptors]: https://docs.oracle.com/javase/specs/jvms/se21/html/jvms-4.html#jvms-4.3.2 diff --git a/versioned_docs/version-1.21.1/advanced/extensibleenums.md b/versioned_docs/version-1.21.1/advanced/extensibleenums.md new file mode 100644 index 000000000..2df255c67 --- /dev/null +++ b/versioned_docs/version-1.21.1/advanced/extensibleenums.md @@ -0,0 +1,149 @@ +# Extensible Enums + +Extensible Enums are an enhancement of specific Vanilla enums to allow new entries to be added. This is done by modifying the compiled bytecode of the enum at runtime to add the elements. + +## `IExtensibleEnum` + +All enums that can have new entries implement the `IExtensibleEnum` interface. This interface acts as a marker to allow the `RuntimeEnumExtender` launch plugin service to know what enums should be transformed. + +:::warning +You should **not** be implementing this interface on your own enums. Use maps or registries instead depending on your usecase. +Enums which are not patched to implement the interface cannot have the interface added to them via mixins or coremods due to the order the transformers run in. +::: + +### Creating an Enum Entry + +To create new enum entries, a JSON file needs to be created and referenced in the `neoforge.mods.toml` with the `enumExtensions` entry of a `[[mods]]` block. The specified path must be relative to the `resources` directory: +```toml +# In neoforge.mods.toml: +[[mods]] +## The file is relative to the output directory of the resources, or the root path inside the jar when compiled +## The 'resources' directory represents the root output directory of the resources +enumExtensions="META-INF/enumextensions.json" +``` + +The definition of the entry consists of the target enum's class name, the new field's name (must be prefixed with the mod ID), the descriptor of the constructor to use for constructing the entry and the parameters to be passed to said constructor. + +```json5 +{ + "entries": [ + { + // The enum class the entry should be added to + "enum": "net/minecraft/world/item/ItemDisplayContext", + // The field name of the new entry, must be prefixed with the mod ID + "name": "EXAMPLEMOD_STANDING", + // The constructor to be used + "constructor": "(ILjava/lang/String;Ljava/lang/String;)V", + // Constant parameters provided directly. + "parameters": [ -1, "examplemod:standing", null ] + }, + { + "enum": "net/minecraft/world/item/Rarity", + "name": "EXAMPLEMOD_CUSTOM", + "constructor": "(ILjava/lang/String;Ljava/util/function/UnaryOperator;)V", + // The parameters to be used, provided as a reference to an EnumProxy field in the given class + "parameters": { + "class": "example/examplemod/MyEnumParams", + "field": "CUSTOM_RARITY_ENUM_PROXY" + } + }, + { + "enum": "net/minecraft/world/damagesource/DamageEffects", + "name": "EXAMPLEMOD_TEST", + "constructor": "(Ljava/lang/String;Ljava/util/function/Supplier;)V", + // The parameters to be used, provided as a reference to a method in the given class + "parameters": { + "class": "example/examplemod/MyEnumParams", + "method": "getTestDamageEffectsParameter" + } + } + ] +} +``` + +```java +public class MyEnumParams { + public static final EnumProxy CUSTOM_RARITY_ENUM_PROXY = new EnumProxy<>( + Rarity.class, -1, "examplemod:custom", (UnaryOperator