Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

hey guys , who knows how to add custom sword enchantment by default , like at twithlight forest mod? that i would be show in creative to

Proud mod developer of:

 

Mob Armor mod

Block monster mod

Clay Living Dolls mod

Much More Spiders mod

Elemental cows reborn

Mr gorilla mod

  • Author

bump, how add one, by default on sword or armor, like in creative tab and it will work to

Proud mod developer of:

 

Mob Armor mod

Block monster mod

Clay Living Dolls mod

Much More Spiders mod

Elemental cows reborn

Mr gorilla mod

You can create your own enchantment class and declare it in your mod class

 

 

 

package claygolem.util;

import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnumEnchantmentType;

public class EnchantmentTest extends Enchantment {
    private static final String __OBFID = "CL_00000100";

    public EnchantmentTest(int effectID, int weight) {
        super(effectID, weight, EnumEnchantmentType.weapon);
        this.setName("testEnchantment");
    }

    /**
     * Returns the minimal value of enchantability needed on the enchantment level passed.
     */
    public int getMinEnchantability(int par1) {
        return 20;
    }

    /**
     * Returns the maximum value of enchantability nedded on the enchantment level passed.
     */
    public int getMaxEnchantability(int par1) {
        return 50;
    }

    /**
     * Returns the maximum level that the enchantment can have.
     */
    public int getMaxLevel() {
        return 1;
    }
}

 

 

 

in your mod class, add the following:

/** custom enchantment 'Test' */
public static final Enchantment test = new EnchantmentTest(113, 0);//id's may not conflict, maybe register the id in a config so it stays compatible with other mods.

  • Author

how to make that enchantment usable?

Proud mod developer of:

 

Mob Armor mod

Block monster mod

Clay Living Dolls mod

Much More Spiders mod

Elemental cows reborn

Mr gorilla mod

Well you can write an event that triggers when the player hits an entity.

 

//I don't know which event it is, you would have to look it up yourself.

        EntityPlayer player = event.Player;
        ItemStack stack = player.inventory.getCurrentItem();
        if(stack != null && stack.isItemEnchanted()) {
        	if(EnchantmentHelper.getEnchantmentLevel(Enchantment.baneOfArthropods.effectId, stack) > 0)
        		System.out.println("BoA");//do effect
        }

 

Using the EnchantmentHelper class, you can check for all enchantments on the itemstack using EnchantmentHelper#getEnchantments this will return a hashmap.

I used it to combine effect, like if horse armor had fire aspect + some custom ones, do the following.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.