Enchantement qui n'exite pas



  • Bonjour, j'ai un problème c'est que mon enchantement n’existe pas !

    Voici mes class:

    Class principale:

    mport java.io.File;
     
    import org.lwjgl.opengl.GL11;
    import org.lwjgl.util.Color;
     
    import com.google.common.base.Throwables;
     
    import NetworkRegistry.INSTANCE.GuiHandler;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.gui.Gui;
    import net.minecraft.client.gui.GuiButton;
    import net.minecraft.client.gui.GuiIngameMenu;
    import net.minecraft.client.gui.GuiMainMenu;
    import net.minecraft.client.gui.GuiOptions;
    import net.minecraft.client.gui.GuiScreen;
    import net.minecraft.client.model.ModelBiped;
    import net.minecraft.client.renderer.entity.RenderItem;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.enchantment.Enchantment;
    import net.minecraft.entity.EnumCreatureType;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.passive.EntitySheep;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraftforge.client.event.GuiOpenEvent;
    import net.minecraftforge.client.event.GuiScreenEvent.InitGuiEvent;
    import net.minecraftforge.client.event.RenderGameOverlayEvent;
    import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType;
    import net.minecraftforge.common.MinecraftForge;
    import net.minecraftforge.event.entity.living.LivingDeathEvent;
    import net.minecraftforge.event.entity.player.FillBucketEvent;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fluids.FluidContainerRegistry;
    import net.minecraftforge.fluids.FluidRegistry;
    import cpw.mods.fml.client.FMLClientHandler;
    import cpw.mods.fml.client.registry.RenderingRegistry;
    import cpw.mods.fml.common.FMLCommonHandler;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.EventHandler;
    import cpw.mods.fml.common.Mod.Instance;
    import cpw.mods.fml.common.SidedProxy;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    import cpw.mods.fml.common.event.FMLServerStartingEvent;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
    import cpw.mods.fml.common.gameevent.TickEvent;
    import cpw.mods.fml.common.gameevent.TickEvent.Phase;
    import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent;
    import cpw.mods.fml.common.network.IGuiHandler;
    import cpw.mods.fml.common.network.NetworkRegistry;
    import cpw.mods.fml.common.registry.EntityRegistry;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.common.registry.LanguageRegistry;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import fr.slimemod.blocks.ForgeSubscribe;
    import fr.slimemod.enchantement.EnchantmentList;
    import fr.slimemod.enchantement.EnchantmentSpecial;
    import fr.slimemod.entity.EntityDynamite;
    import fr.slimemod.gui.F3;
    import fr.slimemod.gui.MenuGui;
    import fr.slimemod.init.BlockMod;
    import fr.slimemod.init.ItemMod;
    import fr.slimemod.proxy.CommonProxy;
    import fr.slimemod.world.WorldRegister;
     
    @Mod(modid = Reference.MOD_NAME, version = Reference.VERSION)
     
    public class SlimeMod
    {
     
     
        @SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY)
        public static CommonProxy proxy;
        
        public static CreativeTabs Slime = new CreativeTabs("SlimeCraft")
        {       
            @Override
            public Item getTabIconItem()
            {
                return ItemMod.slime_ingot;
            }
        };
         
        public void preInit(FMLPreInitializationEvent event)
        {
            enchantSpecial = new EnchantmentSpecial().setName("enchantSpecial");
            MinecraftForge.EVENT_BUS.register(new EnchantmentList());
        }
     
        @EventHandler
        public void Init(FMLInitializationEvent event)
        {
            BlockMod.init();
            BlockMod.register();
            ItemMod.init();
            ItemMod.register();
            WorldRegister.MainRegistry();
            EntityRegistry.registerModEntity(EntityDynamite.class, "EntityDynamite", 420, SlimeMod.instance, 32, 20, false);
            NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler()); 
            MinecraftForge.EVENT_BUS.register(new MenuGui());
            MinecraftForge.EVENT_BUS.register(new F3());
            proxy.registerRenders();
            proxy.registerOverlay();
            proxy.registerRender();
        }
        
        @Instance(Reference.MOD_NAME)
        public static SlimeMod instance;
     
     
     
        @EventHandler
        public void postInit(FMLPostInitializationEvent event)
        {
        }
            
        
        
        
        
        
        @EventHandler
        public void serverStarting(FMLServerStartingEvent event)
        {
            
        }    
        
        public static Enchantment enchantSpecial;
         
    }
    

    Class EnchantmentSpecial:

    import net.minecraft.enchantment.Enchantment;
    import net.minecraft.enchantment.EnumEnchantmentType;
     
    public class EnchantmentSpecial extends Enchantment {
        
        public EnchantmentSpecial() {
            super(250, 0, EnumEnchantmentType.weapon);
        }
        
        public int getMaxLevel() {
            return 30;
    }
    }
    

    et la class EnchantmentList:

    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.item.ItemStack;
    import net.minecraft.potion.Potion;
    import net.minecraft.potion.PotionEffect;
    import net.minecraftforge.event.entity.living.LivingHurtEvent;
    import cpw.mods.fml.common.eventhandler.SubscribeEvent;
     
    public class EnchantmentList
    {
     
        private EntityLivingBase entity;
     
        @SubscribeEvent
        public void onHurt(LivingHurtEvent event) {
            if (event.source.getEntity() instanceof EntityLivingBase) {
                EntityLivingBase entity = (EntityLivingBase) event.source.getEntity();
                if (entity.getHeldItem() != null) {
                    if (hasEnchantment(entity.getHeldItem(), 250)) {
                        event.entityLiving.addPotionEffect(new PotionEffect(Potion.poison.id, 300, 0));
                    }
                }
            }
        }
     
        public boolean hasEnchantment(ItemStack stack, int id) {
            boolean flag = false;
            if (stack.getEnchantmentTagList() != null) {
                for (int i = 0; i < stack.getEnchantmentTagList().tagCount(); i++) {
                    if (stack.getEnchantmentTagList().getCompoundTagAt(i).getShort("id") == id) {
                        flag = true;
                    } else {
                        flag = false;
                    }
                }
            }
            return flag;
        }
    }
    

    Merci d’avance



  • T'as essayé le /enchant?



  • Oui j'ai essayer mais CA me dit que l’enchantement 250 n’existe pas


Log in to reply