From c17721cb40b03c1dd7150a4955c748fb98867a23 Mon Sep 17 00:00:00 2001 From: "Calum H." Date: Wed, 15 Jan 2025 11:28:55 +0000 Subject: [PATCH] Update to 1.21.4: Niche Pages (#258) --- develop/data-generation/advancements.md | 22 +++----- develop/data-generation/tags.md | 2 +- develop/data-generation/translations.md | 2 +- develop/entities/damage-types.md | 12 +++-- ...ricDocsReferenceInternalModelProvider.java | 54 ------------------- ...abricDocsReferenceAdvancementProvider.java | 8 +-- ...ricDocsReferenceInternalModelProvider.java | 1 - .../advancement}/apple_and_beef.json | 2 +- .../advancement}/break_block_with_tool.json | 2 +- .../break_block_with_tool_five_times.json | 2 +- .../advancement}/get_dirt.json | 0 .../com/example/docs/block/ModBlocks.java | 2 +- .../docs/item/FabricDocsReferenceItems.java | 1 - .../docs/item/armor/GuiditeArmorMaterial.java | 3 +- 14 files changed, 26 insertions(+), 87 deletions(-) delete mode 100644 reference/1.21/src/client/java/com/example/docs/datagen/util/FabricDocsReferenceInternalModelProvider.java rename reference/latest/src/main/generated/data/{minecraft/advancement/fabric-docs-reference => fabric-docs-reference/advancement}/apple_and_beef.json (92%) rename reference/latest/src/main/generated/data/{minecraft/advancement/fabric-docs-reference => fabric-docs-reference/advancement}/break_block_with_tool.json (88%) rename reference/latest/src/main/generated/data/{minecraft/advancement/fabric-docs-reference => fabric-docs-reference/advancement}/break_block_with_tool_five_times.json (88%) rename reference/latest/src/main/generated/data/{minecraft/advancement/fabric-docs-reference => fabric-docs-reference/advancement}/get_dirt.json (100%) diff --git a/develop/data-generation/advancements.md b/develop/data-generation/advancements.md index 9f8a1fd98..45bda31c2 100644 --- a/develop/data-generation/advancements.md +++ b/develop/data-generation/advancements.md @@ -24,7 +24,7 @@ First, we need to make our provider. Create a class that `extends FabricAdvancem To finish setup, add this provider to your `DataGeneratorEntrypoint` within the `onInitializeDataGenerator` method. -@[code lang=java transclude={24-24}](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceDataGenerator.java) +@[code lang=java transclude={25-25}](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceDataGenerator.java) ## Advancement Structure {#advancement-structure} @@ -42,8 +42,12 @@ Here's a simple advancement for getting a dirt block: @[code lang=java transcludeWith=:::datagen-advancements:simple-advancement](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceAdvancementProvider.java) +::: warning +When building your advancement entries, remember that the function accepts the `Identifier` of the advancement in `String` format! +::: + ::: details JSON Output -@[code lang=json](@/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/fabric-docs-reference/get_dirt.json) +@[code lang=json](@/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/get_dirt.json) ::: ## One More Example {#one-more-example} @@ -52,20 +56,6 @@ Just to get the hang of it, let's add one more advancement. We'll practice addin @[code lang=java transcludeWith=:::datagen-advancements:second-advancement](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceAdvancementProvider.java) -Don't forget to generate them! Use the terminal command below or the run configuration in IntelliJ. - -::: code-group - -```sh [Windows] -gradlew runDatagen -``` - -```sh [Linux] -./gradlew runDatagen -``` - -::: - ## Custom Criteria {#custom-criteria} ::: warning diff --git a/develop/data-generation/tags.md b/develop/data-generation/tags.md index db8b0ede1..7a0c2b20a 100644 --- a/develop/data-generation/tags.md +++ b/develop/data-generation/tags.md @@ -27,7 +27,7 @@ You will need a different provider for each type of tag (eg. one `FabricTagProvi To finish setup, add this provider to your `DataGeneratorEntrypoint` within the `onInitializeDataGenerator` method. -@[code lang=java transclude={28-28}](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceDataGenerator.java) +@[code lang=java transclude={29-29}](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceDataGenerator.java) ## Creating a Tag {#creating-a-tag} diff --git a/develop/data-generation/translations.md b/develop/data-generation/translations.md index 62f985ad5..1392357a8 100644 --- a/develop/data-generation/translations.md +++ b/develop/data-generation/translations.md @@ -30,7 +30,7 @@ You will need a different provider for each langauge you want to generate (eg. o To finish setup, add this provider to your `DataGeneratorEntrypoint` within the `onInitializeDataGenerator` method. -@[code lang=java transclude={26-26}](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceDataGenerator.java) +@[code lang=java transclude={27-27}](@/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceDataGenerator.java) ## Creating Translations {#creating-translations} diff --git a/develop/entities/damage-types.md b/develop/entities/damage-types.md index 466e298a6..90dd926de 100644 --- a/develop/entities/damage-types.md +++ b/develop/entities/damage-types.md @@ -55,11 +55,11 @@ You can override `onSteppedOn` to inflict this damage. We start by creating a `DamageSource` of our custom damage type. -@[code lang=java transclude={21-24}](@/reference/latest/src/main/java/com/example/docs/damage/TaterBlock.java) +@[code lang=java transclude={22-26}](@/reference/latest/src/main/java/com/example/docs/damage/TaterBlock.java) Then, we call `entity.damage()` with our `DamageSource` and an amount. -@[code lang=java transclude={25-25}](@/reference/latest/src/main/java/com/example/docs/damage/TaterBlock.java) +@[code lang=java transclude={27-27}](@/reference/latest/src/main/java/com/example/docs/damage/TaterBlock.java) The complete block implementation: @@ -72,7 +72,13 @@ Now whenever a living entity steps on our custom block, it'll take 5 damage (2.5 You can define a death message for the damage type in the format of `death.attack.` in our mod's `en_us.json` file. -@[code lang=json transclude={4-4}](@/reference/latest/src/main/resources/assets/fabric-docs-reference/lang/en_us.json) +```json +{ + // ... + "death.attack.tater": "%1$s died from Tater damage!", + // ... +} +``` Upon death from our damage type, you'll see the following death message: diff --git a/reference/1.21/src/client/java/com/example/docs/datagen/util/FabricDocsReferenceInternalModelProvider.java b/reference/1.21/src/client/java/com/example/docs/datagen/util/FabricDocsReferenceInternalModelProvider.java deleted file mode 100644 index 8becc10d4..000000000 --- a/reference/1.21/src/client/java/com/example/docs/datagen/util/FabricDocsReferenceInternalModelProvider.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.example.docs.datagen.util; - -import com.example.docs.FabricDocsReference; -import com.example.docs.block.ModBlocks; - -import com.example.docs.block.custom.PrismarineLampBlock; - -import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput; -import net.fabricmc.fabric.api.datagen.v1.provider.FabricModelProvider; - -import net.minecraft.data.client.BlockStateModelGenerator; -import net.minecraft.data.client.BlockStateVariant; -import net.minecraft.data.client.ItemModelGenerator; -import net.minecraft.data.client.ModelIds; -import net.minecraft.data.client.MultipartBlockStateSupplier; -import net.minecraft.data.client.VariantSettings; -import net.minecraft.data.client.When; -import net.minecraft.util.Identifier; - -/** - * This generator is just for the reference item and block models. - * Not for describing how to use the model provider. - */ -public class FabricDocsReferenceInternalModelProvider extends FabricModelProvider { - public FabricDocsReferenceInternalModelProvider(FabricDataOutput output) { - super(output); - } - - @Override - public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) { - blockStateModelGenerator.registerSimpleCubeAll(ModBlocks.CONDENSED_DIRT); - blockStateModelGenerator.registerSimpleCubeAll(ModBlocks.COUNTER_BLOCK); - - // TODO: This would be a good example for the model generation page. Move when needed. - blockStateModelGenerator.blockStateCollector.accept(MultipartBlockStateSupplier.create(ModBlocks.PRISMARINE_LAMP) - .with(When.create().set(PrismarineLampBlock.ACTIVATED, true), - BlockStateVariant.create().put(VariantSettings.MODEL, ModelIds.getBlockSubModelId(ModBlocks.PRISMARINE_LAMP, "on"))) - .with(When.create().set(PrismarineLampBlock.ACTIVATED, false), - BlockStateVariant.create().put(VariantSettings.MODEL, ModelIds.getBlockModelId(ModBlocks.PRISMARINE_LAMP))) - ); - - blockStateModelGenerator.registerAxisRotated(ModBlocks.CONDENSED_OAK_LOG, Identifier.of(FabricDocsReference.MOD_ID, "block/condensed_oak_log")); - } - - @Override - public void generateItemModels(ItemModelGenerator itemModelGenerator) { - - } - - @Override - public String getName() { - return "FabricDocsReference Internal Model Provider"; - } -} diff --git a/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceAdvancementProvider.java b/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceAdvancementProvider.java index cb5e421bf..49e40671f 100644 --- a/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceAdvancementProvider.java +++ b/reference/latest/src/client/java/com/example/docs/datagen/FabricDocsReferenceAdvancementProvider.java @@ -48,7 +48,7 @@ public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Con // "got_dirt" is the name referenced by other advancements when they want to have "requirements." .criterion("got_dirt", InventoryChangedCriterion.Conditions.items(Items.DIRT)) // Give the advancement an id - .build(consumer, FabricDocsReference.MOD_ID + "/get_dirt"); + .build(consumer, FabricDocsReference.MOD_ID + ":get_dirt"); // :::datagen-advancements:simple-advancement // :::datagen-advancements:second-advancement final RegistryWrapper.Impl itemLookup = wrapperLookup.getOrThrow(RegistryKeys.ITEM); @@ -66,7 +66,7 @@ public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Con ) .criterion("ate_apple", ConsumeItemCriterion.Conditions.item(wrapperLookup.getOrThrow(RegistryKeys.ITEM), Items.APPLE)) .criterion("ate_cooked_beef", ConsumeItemCriterion.Conditions.item(itemLookup, Items.COOKED_BEEF)) - .build(consumer, FabricDocsReference.MOD_ID + "/apple_and_beef"); + .build(consumer, FabricDocsReference.MOD_ID + ":apple_and_beef"); // :::datagen-advancements:second-advancement // :::datagen-advancements:custom-criteria-advancement AdvancementEntry breakBlockWithTool = Advancement.Builder.create() @@ -82,7 +82,7 @@ public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Con false ) .criterion("break_block_with_tool", ModCriteria.USE_TOOL.create(new UseToolCriterion.Conditions(Optional.empty()))) - .build(consumer, FabricDocsReference.MOD_ID + "/break_block_with_tool"); + .build(consumer, FabricDocsReference.MOD_ID + ":break_block_with_tool"); // :::datagen-advancements:custom-criteria-advancement // :::datagen-advancements:new-custom-criteria-advancement AdvancementEntry breakBlockWithToolFiveTimes = Advancement.Builder.create() @@ -98,7 +98,7 @@ public void generateAdvancement(RegistryWrapper.WrapperLookup wrapperLookup, Con false ) .criterion("break_block_with_tool_five_times", ModCriteria.PARAMETERIZED_USE_TOOL.create(new ParameterizedUseToolCriterion.Conditions(Optional.empty(), 5))) - .build(consumer, FabricDocsReference.MOD_ID + "/break_block_with_tool_five_times"); + .build(consumer, FabricDocsReference.MOD_ID + ":break_block_with_tool_five_times"); // :::datagen-advancements:new-custom-criteria-advancement // :::datagen-advancements:provider-start } diff --git a/reference/latest/src/client/java/com/example/docs/datagen/internal/FabricDocsReferenceInternalModelProvider.java b/reference/latest/src/client/java/com/example/docs/datagen/internal/FabricDocsReferenceInternalModelProvider.java index 7f45ec068..902876d83 100644 --- a/reference/latest/src/client/java/com/example/docs/datagen/internal/FabricDocsReferenceInternalModelProvider.java +++ b/reference/latest/src/client/java/com/example/docs/datagen/internal/FabricDocsReferenceInternalModelProvider.java @@ -16,7 +16,6 @@ import com.example.docs.block.custom.PrismarineLampBlock; import com.example.docs.item.ModItems; - /** * This generator is just for the reference item and block models. * Not for describing how to use the model provider. diff --git a/reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/apple_and_beef.json b/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/apple_and_beef.json similarity index 92% rename from reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/apple_and_beef.json rename to reference/latest/src/main/generated/data/fabric-docs-reference/advancement/apple_and_beef.json index 89b80a9d0..a5e3509f7 100644 --- a/reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/apple_and_beef.json +++ b/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/apple_and_beef.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:fabric-docs-reference/get_dirt", + "parent": "fabric-docs-reference:get_dirt", "criteria": { "ate_apple": { "conditions": { diff --git a/reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/break_block_with_tool.json b/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/break_block_with_tool.json similarity index 88% rename from reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/break_block_with_tool.json rename to reference/latest/src/main/generated/data/fabric-docs-reference/advancement/break_block_with_tool.json index 22e73787b..9cb64eff1 100644 --- a/reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/break_block_with_tool.json +++ b/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/break_block_with_tool.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:fabric-docs-reference/get_dirt", + "parent": "fabric-docs-reference:get_dirt", "criteria": { "break_block_with_tool": { "trigger": "minecraft:fabric-docs-reference/use_tool" diff --git a/reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/break_block_with_tool_five_times.json b/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/break_block_with_tool_five_times.json similarity index 88% rename from reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/break_block_with_tool_five_times.json rename to reference/latest/src/main/generated/data/fabric-docs-reference/advancement/break_block_with_tool_five_times.json index 7e2158881..e76733a8c 100644 --- a/reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/break_block_with_tool_five_times.json +++ b/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/break_block_with_tool_five_times.json @@ -1,5 +1,5 @@ { - "parent": "minecraft:fabric-docs-reference/break_block_with_tool", + "parent": "fabric-docs-reference:break_block_with_tool", "criteria": { "break_block_with_tool_five_times": { "conditions": { diff --git a/reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/get_dirt.json b/reference/latest/src/main/generated/data/fabric-docs-reference/advancement/get_dirt.json similarity index 100% rename from reference/latest/src/main/generated/data/minecraft/advancement/fabric-docs-reference/get_dirt.json rename to reference/latest/src/main/generated/data/fabric-docs-reference/advancement/get_dirt.json diff --git a/reference/latest/src/main/java/com/example/docs/block/ModBlocks.java b/reference/latest/src/main/java/com/example/docs/block/ModBlocks.java index 3e588e957..d503a9bb8 100644 --- a/reference/latest/src/main/java/com/example/docs/block/ModBlocks.java +++ b/reference/latest/src/main/java/com/example/docs/block/ModBlocks.java @@ -89,7 +89,7 @@ public static Block register(Block block, RegistryKey blockKey, boolean s // Sometimes, you may not want to register an item for the block. // Eg: if it's a technical block like `minecraft:air` or `minecraft:end_gateway` if (shouldRegisterItem) { - // Items need to be registered with a different type of registry key, but the ID + // Items need to be registered with a different type of registry key, but the ID // can be the same. RegistryKey itemKey = RegistryKey.of(RegistryKeys.ITEM, blockKey.getValue()); diff --git a/reference/latest/src/main/java/com/example/docs/item/FabricDocsReferenceItems.java b/reference/latest/src/main/java/com/example/docs/item/FabricDocsReferenceItems.java index 484a4bd78..68d98da4a 100644 --- a/reference/latest/src/main/java/com/example/docs/item/FabricDocsReferenceItems.java +++ b/reference/latest/src/main/java/com/example/docs/item/FabricDocsReferenceItems.java @@ -2,7 +2,6 @@ import net.fabricmc.api.ModInitializer; - // :::1 public class FabricDocsReferenceItems implements ModInitializer { @Override diff --git a/reference/latest/src/main/java/com/example/docs/item/armor/GuiditeArmorMaterial.java b/reference/latest/src/main/java/com/example/docs/item/armor/GuiditeArmorMaterial.java index d81d34cb6..93126a613 100644 --- a/reference/latest/src/main/java/com/example/docs/item/armor/GuiditeArmorMaterial.java +++ b/reference/latest/src/main/java/com/example/docs/item/armor/GuiditeArmorMaterial.java @@ -16,7 +16,6 @@ import com.example.docs.FabricDocsReference; public class GuiditeArmorMaterial { - // :::base_durability public static final int BASE_DURABILITY = 15; // :::base_durability @@ -46,4 +45,4 @@ public class GuiditeArmorMaterial { GUIDITE_ARMOR_MATERIAL_KEY ); // :::guidite_armor_material -} \ No newline at end of file +}