Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a guide for Custom Enchantments #134

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

krizh-p
Copy link

@krizh-p krizh-p commented Jul 9, 2024

I wrote a guide for creating Custom Enchantment Effects as 1.21 completetly changes how enchantments must be made.

@krizh-p krizh-p requested a review from a team as a code owner July 9, 2024 19:29
Copy link

netlify bot commented Jul 9, 2024

Deploy Preview for nimble-elf-d9d491 ready!

Name Link
🔨 Latest commit 1cc3cb2
🔍 Latest deploy log https://app.netlify.com/sites/nimble-elf-d9d491/deploys/66b26b37bafb87000815001c
😎 Deploy Preview https://deploy-preview-134--nimble-elf-d9d491.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@krizh-p krizh-p changed the title finished the guide for custom enchantment effects Add a guide for Custom Enchantments Jul 9, 2024
@IMB11 IMB11 added new-content A new page or set of pages stage:cleanup This should be cleaned up labels Jul 9, 2024
Copy link
Member

@IMB11 IMB11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a bit to do, but it's a great start - the structure is definitely there, it just needs the following done:

  • Breaking up larger paragraphs into seperate paragraphs (especially the start and the "Creating The Enchantment" first paragraph.
  • Delegating the datagen setup information to the relevant Fabric Wiki page
  • Fix issues with markdown-lint, see either the files tab on this PR to see the issues, or view the github action logs, you can also use the vscode plugin to find all lint issues.
  • Moving code from code blocks into the reference mod.
  • Using either an LLM or a tool such as LanguageTool to ensure grammar and readability is good.

Overall, this is a great guide, it really uses all the features of the wiki, and will be really useful for many developers! Good job! 👍

develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
@krizh-p
Copy link
Author

krizh-p commented Jul 9, 2024

Just went through and fixed everything mentioned in the code review

@krizh-p krizh-p requested a review from IMB11 July 9, 2024 21:10
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
applied suggested grammar fixes

Co-authored-by: Miroma <[email protected]>
Copy link
Author

@krizh-p krizh-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accepted fixes in grammar

@krizh-p krizh-p requested a review from its-miroma July 17, 2024 14:17
Copy link
Member

@its-miroma its-miroma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am only reviewing the Markdown file, not the Java code; that should be reviewed by someone else.

develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
develop/items/custom-enchantment-effects.md Outdated Show resolved Hide resolved
Copy link
Contributor

@JR1811 JR1811 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small and mostly "clean-code" related stuff.

@IMB11
Copy link
Member

IMB11 commented Aug 6, 2024

I have cleaned up the introduction and final sentences, this is good IMO.

@IMB11 IMB11 requested a review from its-miroma August 7, 2024 14:15

## Custom Enchantment Effects {#custom-enchantment-effects}

Start by creating an `enchantment` folder, and within it create a folder `effect`. Within the `effect` folder, we'll create the `LightningEnchantmentEffect` record.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Start by creating an `enchantment` folder, and within it create a folder `effect`. Within the `effect` folder, we'll create the `LightningEnchantmentEffect` record.
Start by creating an `enchantment` folder, and within it, create an `effect` folder. Within that, we'll create the `LightningEnchantmentEffect` record.


Start by creating an `enchantment` folder, and within it create a folder `effect`. Within the `effect` folder, we'll create the `LightningEnchantmentEffect` record.

Next, we can create a constructor and override the `EnchantmentEntityEffect` interface methods. We'll also create `CODEC` variable to encode and decode our effect; you can read more about [Codecs here](../codecs).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Next, we can create a constructor and override the `EnchantmentEntityEffect` interface methods. We'll also create `CODEC` variable to encode and decode our effect; you can read more about [Codecs here](../codecs).
Next, we can create a constructor and override the `EnchantmentEntityEffect` interface methods. We'll also create a `CODEC` variable to encode and decode our effect; you can read more about [Codecs here](../codecs).


Next, we can create a constructor and override the `EnchantmentEntityEffect` interface methods. We'll also create `CODEC` variable to encode and decode our effect; you can read more about [Codecs here](../codecs).

The bulk of our code will go into the `apply()` event, which is called when the criteria for your enchantment to work is met. We'll later configure this `Effect` to be called when an entity is hit, but for now let's write simple code to strike the target with lightning.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The bulk of our code will go into the `apply()` event, which is called when the criteria for your enchantment to work is met. We'll later configure this `Effect` to be called when an entity is hit, but for now let's write simple code to strike the target with lightning.
The bulk of our code will go into the `apply()` event, which is called when the criteria for your enchantment to work is met. We'll later configure this `Effect` to be called when an entity is hit, but for now, let's write simple code to strike the target with lightning.


@[code transcludeWith=#entrypoint](@/reference/latest/src/main/java/com/example/docs/enchantment/effect/LightningEnchantmentEffect.java)

Here the `amount` variable indicates a value scaled to the level of the enchantment. We can use this to modify how effective the enchantment is based on level. In the code above, we are using the level of the enchantment to determine how many lightning strikes are spawned.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Here the `amount` variable indicates a value scaled to the level of the enchantment. We can use this to modify how effective the enchantment is based on level. In the code above, we are using the level of the enchantment to determine how many lightning strikes are spawned.
Here, the `amount` variable indicates a value scaled to the level of the enchantment. We can use this to modify how effective the enchantment is based on level. In the code above, we are using the level of the enchantment to determine how many lightning strikes are spawned.


## Registering the Enchantment Effect {#registering-the-enchantment-effect}

Like every other component of your mod, we'll have to add this `EnchantmentEffect` to Minecraft's registry. To do so, add a class `ModEnchantmentEffects` (or whatever you want to name it) and a helper method to register the enchantment. Be sure to call the `registerModEnchantmentEffects()` in your main class which contains the `onInitialize()` method.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Like every other component of your mod, we'll have to add this `EnchantmentEffect` to Minecraft's registry. To do so, add a class `ModEnchantmentEffects` (or whatever you want to name it) and a helper method to register the enchantment. Be sure to call the `registerModEnchantmentEffects()` in your main class which contains the `onInitialize()` method.
Like every other component of your mod, we'll have to add this `EnchantmentEffect` to Minecraft's registry. To do so, add a class `ModEnchantmentEffects` (or whatever you want to name it) and a helper method to register the enchantment. Be sure to call the `registerModEnchantmentEffects()` in your main class, which contains the `onInitialize()` method.

"enchantment.FabricDocsReference.thundering": "Thundering",
```

You should now have a working custom enchantment effect! You can test it by enchanting a weapon with the enchantment and hitting a mob, an example is given in the following video.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You should now have a working custom enchantment effect! You can test it by enchanting a weapon with the enchantment and hitting a mob, an example is given in the following video.
You should now have a working custom enchantment effect! Test it by enchanting a weapon with the enchantment and hitting a mob. An example is given in the following video:


# Custom Enchantments {#custom-enchantments}

Starting from version 1.21, custom enchantments in Minecraft use a "data-driven" approach. This makes it easier to add simple enchantments, like increasing attack damage, but more challenging to create complex ones. The process involves breaking down enchantments into _effect components_.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting from version 1.21

Does this have to be mentioned here? The plugin already highlights it.

in Minecraft

Again, the entire Fabric project revolves around Minecraft, no need to specify it in every page IMO.

Comment on lines +12 to +16
An effect component contains the code that defines the special effects of an enchantment. Minecraft supports various default effects, such as item damage, knockback, and experience.

However, this guide focuses on creating custom enchantment effects that aren't supported by default.

**Before continuing, please check if the default Minecraft effects can work for your needs by visiting [the Minecraft Wiki's Enchantment Effect Components page](https://minecraft.wiki/w/Enchantment_definition#Effect_components)**. The rest of the guide assumes you understand how to configure "simple" data-driven enchantments.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An effect component contains the code that defines the special effects of an enchantment. Minecraft supports various default effects, such as item damage, knockback, and experience.
However, this guide focuses on creating custom enchantment effects that aren't supported by default.
**Before continuing, please check if the default Minecraft effects can work for your needs by visiting [the Minecraft Wiki's Enchantment Effect Components page](https://minecraft.wiki/w/Enchantment_definition#Effect_components)**. The rest of the guide assumes you understand how to configure "simple" data-driven enchantments.
An effect component contains the code that defines the special effects of an enchantment. Minecraft supports various default effects, such as item damage, knockback, and experience.
::: tip
Be sure to check if the default Minecraft effects satisfy your needs by visiting [the Minecraft Wiki's Enchantment Effect Components page](https://minecraft.wiki/w/Enchantment_definition#Effect_components). This guide assumes you understand how to configure "simple" data-driven enchantments and focuses on creating custom enchantment effects that aren't supported by default.
:::


Starting from version 1.21, custom enchantments in Minecraft use a "data-driven" approach. This makes it easier to add simple enchantments, like increasing attack damage, but more challenging to create complex ones. The process involves breaking down enchantments into _effect components_.

An effect component contains the code that defines the special effects of an enchantment. Minecraft supports various default effects, such as item damage, knockback, and experience.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
An effect component contains the code that defines the special effects of an enchantment. Minecraft supports various default effects, such as item damage, knockback, and experience.
An effect component contains the code that defines the special effects of an enchantment. Minecraft supports various default effects, such as item damage, knockback, and experience.

@its-miroma its-miroma added stage:verification This should be verified and removed stage:cleanup This should be cleaned up labels Oct 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-content A new page or set of pages stage:verification This should be verified
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants