Giancarlo Garcia Deleon
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # Minecraft Modding - Part 1 ## Setting up the Environment [Java 16](https://www.oracle.com/java/technologies/javase-downloads.html) - The current Java version supported by the Fabric Mod [IntelliJ IDEA](https://www.jetbrains.com/idea/download/#section=windows) - Recommended: Community - We will use this application to build out our Java code for the mod [WinRAR](https://www.rarlab.com/download.htm) - Recommended: WinRAR x64 (64 bit) 6.02 - For macOS, No need to for zip software - Merely to unzip files, unneeded if familiar with Git Clone the following [Fabric Mod Example](https://github.com/FabricMC/fabric-example-mod/) from the Fabric API ## Reading Material [Fabric API Wiki Page](https://fabricmc.net/wiki/tutorial:migratemappings) The plugin can be found in the IntelliJ plugin repository, so you can install it using IntelliJ's internal plugin browser by navigating to File → Settings → Plugins, then clicking the Marketplace tab and searching for Minecraft. [Intro to Modding with Fabric](https://fabricmc.net/wiki/tutorial:introduction) Please read to gain an understanding of the different tools/dependencies and concepts that have already been created in the past. ### Third Party Libraries [3rd party library mods](https://fabricmc.net/wiki/documentation:libraries) ### Applying changes without restarting Minecraft - Reload changed classes In Eclipse or **Intellij IDEA**, run Minecraft in **debug mode**. To apply changes in code, click the build button in Intellij IDEA or save in Eclipse. Note: this only allows you to change method bodies. If you do any other kind of change, You will have to restart. However, if you use DCEVM *(Not supported by Java 11+)*, you will be able to do most changes, including adding and removing methods and classes. - Reload assets After you make changes to assets such as textures and block/item models, you can rebuild the project and press F3 + T to apply changes without restarting Minecraft. More specifically, this is how to reload anything the mod provides as a resource pack. - Reload data You can apply any changes made in the data/ directory such as recipes, loot tables and tags by rebuilding the project and then using the in-game command /reload. More specifically, this reloads anything the mod provides as a data pack. ## Add a new item - Create new directories under resources/assets - assets/tutorial/item ``` // Create fabric_item.json { "parent": "item/generated", "textures": { "layer0": "tutorial:item/divine_sword" } } ``` - assets/textures/item - Place png texture ![Heart](https://i.imgur.com/QVsnzAH.png) -> https://i.imgur.com/QVsnzAH.png - Create new directories under our example to customize our item - example/item/misc/Heart.java ``` // Create our item public class Heart extends Item { public Heart(Settings settings) { super(settings); } @Override public TypedActionResult<ItemStack> use(World world, PlayerEntity playerEntity, Hand hand) { playerEntity.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 1.0F); return TypedActionResult.success(playerEntity.getStackInHand(hand)); } } ``` - Define our Heart and get ready to run our new minecraft fabric mod ``` public class ExampleMod implements ModInitializer { // An instance of our new item that only stacks 5 times public static final Heart HEART = new Heart(new FabricItemSettings().group(ItemGroup.MISC).maxCount(5)); @Override public void onInitialize() { Registry.register(Registry.ITEM, new Identifier("tutorial", "heart"), HEART); } } ``` To run our minecraft mod, go to to the right panel and click on Gradle Gradle > Tasks > fabric > runClient ### Enhancements - [ ] Make the item a Food item - [ ] Give status effects - [ ] Make the name of the item, "Hearty Meal" To make an item a Food Item, we can reinit our item as an instance of itself and then group the item as FOOD. Then we can declare a new FoodComponent with some status effects. ``` public static final Item HEART = new Heart(new Item.Settings().group(ItemGroup.FOOD).maxCount(5).food(new FoodComponent.Builder().hunger(2).saturationModifier(4f).snack().alwaysEdible().statusEffect(new StatusEffectInstance(StatusEffects.HEALTH_BOOST, 20*3), 0.75f).build())); ``` Let's rename our item to "Heaty Meal" and do away with the java syntax of "item.tutorial.heart". Create a new directory under tutorial named lang. tutorial/lang/en_us.json ``` { "item.tutorial.heart": "Hearty Meal" } ``` All newly made and renamed items can exist above. ## End of Workshop # 1 # Minecraft Modding - Part 2 ## Overview In the previous section, you created a generic item that was able to be used by right-clicking, which you were then challenged to make an edible item. The new task is to instead create an item that acts like a tool. This documentation will walk you through how to create a new type of pickaxe and a new type of sword. We will create an Emerald tier of tools (which can be relatively easy to change and toy with) and set predefined attributes to this tier to easy expand into other tools. You can follow along with this workshop [here](https://fabricmc.net/wiki/tutorial:tools) on the fabric website. ## Tool Tier Within the fabricmc package, create a new package titled accordingly to our current project. I went with "EmeraldTier". Make a new class titled something like "EmeraldTool". Within this class, we'll start with the skeleton of the following: ``` public class EmeraldTool implements ToolMaterial { public static final EmeraldTool INSTANCE = new EmeraldTool(); @Override public int getDurability() { return 0; } @Override public float getMiningSpeedMultiplier() { return 0.0F; } @Override public float getAttackDamage() { return 0.0F; } @Override public int getMiningLevel() { return 0; } @Override public int getEnchantability() { return 0; } @Override public Ingredient getRepairIngredient() { return Ingredient.ofItems(Items.X); } } ``` The beginning declaration says that we are creating a new tool class that can then be easily reused for when we make our actual tools later. The second line lets us apply those attributes to an item we declare as an EmeraldTool. Next are all the attributes of those tools. - getDurability sets the tool durability. The number correlated directly to the number of uses the tool has - getMiningSpeedMultiplier sets the minng speed for breaking valid blocks with such a tool. This multiplier is based off off your hand's mining speed - getAttackDamage sets the damage bonus that all tools in this class recieve. This is separate from attack bonuses from tools (like how swords and axes how higher base damage) - getMiningLevel sets how tough of blocks tools in this class can break. This is mainly for pickaxes; a higher level (up to 4) means the tool can break tougher blocks like obsidian and ancient debris - getEnchantability sets the probabilities for getting stronger enchantments on tools of this class. Higher numbers means better chances for stronger enchantments - getRepairIngredient sets the item type needed to repair this tool class at an anvil. This requires you to know the item ID used by the code, not what appears in game (ex. emerald in Items.E) Follow [this link](https://minecraft.fandom.com/wiki/Tiers) to get an idea of how the base game's tiers are structured so you can play around with the numbers. DO NOT delete the F symbol on this numbers, they declare those numbers to be float-points. Other than that, replace any of those numbers and play around with them as you would like. ## Specific Tool Classes For some reason, pickaxes, axes, and hoes require a little bit of extra work to get them working. Fortunately, this is very easy, so we'll go ahead and cover it now. Next to your EmeraldTier class, make a new class titled something like "EmeraldPickaxeTool". Within it, copy the following code: ``` public class EmeraldPickaxeItem extends PickaxeItem { public EmeraldPickaxeItem(ToolMaterial material, int attackDamage, float attackSpeed, Settings settings) { super(material, attackDamage, attackSpeed, settings); } } ``` In full honestly, I have no idea why we need to do this for these three tools and not swords or shovels, but they don't work without it. ## Setting Up Resources Similarly to what you did in Part 1, we need to create resources for each of our tools to use. This includes a .json file and a .png file. Within your main package, navigate to your resources/assets and make a new folder. Let's call it something like "emeraldtools". Like last time, we'll need two folders here, which we'll put the files for the sword first: - ...emeraldtools/models/item/emerald_sword.json - ...emeraldtools/textures/item/emerald_sword.png For the .json files, you can use the following template: ``` { "parent": "item/generated", "textures": { "layer0": "emeraldtools:item/emerald_sword" } } ``` This tells the code to look for the emerald_sword.png file in the textures resources. So now we better add that. You can use this texture ![emerald_sword](https://i.imgur.com/yH8bufm.png) -> https://i.imgur.com/yH8bufm.png if you would so like, or you can make your own. Item textures are made in 16x16 pixel squares, so any software than can make transparent png's will do. ## Adding Your New Tool Now we need to move back to our main class and add the lines to first declare than register our new tool. Tools follow this format: ``` public static ToolItem <NAME> = new <TOOL>Item(<CLASS>, int baseDamage, float swingSpeed (written as a negative number), new Item.Settings().group(ItemGroup.COMBAT)); ``` This is lengthy and annoying to navigate through, so it may serve you well to ENTER around the commas to make a more readable list of attributes. Nevertheless, for our emerald sword, the declaration should look something like this: ``` public static ToolItem EMERALD_SWORD = new SwordItem(EmeraldItem.INSTANCE, 4, -2.4F, new Item.Settings().group(ItemGroup.COMBAT)); ``` As for the pickaxe, once you have created the .json and .png files for it in the resources, you can declare very similarly, but instead of using "SwordItem", use the name of the custom class you made before, like how I used "EmeraldPickaxeTool". Lastly, we need to register our item. The registry goes similarly as before: ``` Registry.register(Registry.ITEM, new Identifier("emeraldtools", "emerald_sword"), EMERALD_SWORD); ``` This points it to the .json file so that it can properly texture and render the item. And at last, you've added a brand new sword to the game! Go into Creative Mode and check the Combat tab at the bottom, and you should see the emerald sword there. Go ahead and play around with all of its attributes to make sure they're working similarly to how you coded them. ## Enhancements From here, you are let free to expand on these items as you would like. Here's a small checklist of ideas for you to get some ideas of how you'd like to expand this mod: - [ ] Create an emerald pickaxe - [ ] Create an emerald shovel, and hoe - [ ] Add renames to all the items, so they don't show their ID's - [ ] Add [crafting recipes](https://fabricmc.net/wiki/tutorial:recipes) for each of these items - [ ] Add these items to loot pools (dungeon chests, villager trades, enemy drops, or otherwise)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully