Jump to content

Recommended Posts

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

Posted

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

Posted

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.

Posted

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

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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