(Post-Compilation) Crash au lancement



  • Bonjour, après avoir compilé mon mod avec la commande 'gradlew build' et récupéré les sources dans le dossier build (assets, packages et mcmod.info, je précise au cas où il y aurai une erreur), je lance tout naturellement Minecraft Forge (le normal) pour tester si mon mod marche. Et là :

    cpw.mods.fml.common.LoaderException: java.lang.NoSuchFieldError: dragonEgg
    at cpw.mods.fml.common.LoadController.transition(LoadController.java:162)
    at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:514)
    at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:239)
    at net.minecraft.client.Minecraft.func_71384_a(Minecraft.java:467)
    at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:815)
    at net.minecraft.client.main.Main.main(SourceFile:103)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    Caused by: java.lang.NoSuchFieldError: dragonEgg
    at fr.MrBlockTNT.Dragons.block.BlockDragonEgg.<init>(BlockDragonEgg.java:22)
    at fr.MrBlockTNT.Dragons.core.Dragons.PreInit(Dragons.java:58)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:513)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
    at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
    at com.google.common.eventbus.EventBus.post(EventBus.java:267)
    at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:208)
    at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:187)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
    at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296)
    at com.google.common.eventbus.EventBus.post(EventBus.java:267)
    at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:118)
    at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:512)
    … 10 more
    
    

    Code :

    Dragons.java (partie intéressante) :

    package fr.MrBlockTNT.Dragons.core;
    
    import net.minecraft.block.Block;
    import net.minecraft.init.Blocks;
    import cpw.mods.fml.common.registry.GameRegistry;
    import fr.MrBlockTNT.Dragons.block.BlockDragonEgg;
    
    public class Dragons
    {
        public static Block fireDragonEgg;
    
        @EventHandler
        public void PreInit(FMLPreInitializationEvent event)
        {
    
            fireDragonEgg = (new BlockDragonEgg()).setHardness(3.0F).setResistance(15.0F).setBlockName("fireDragonEgg").setBlockTextureName("dragons:fire_dragon_egg").setCreativeTab(Dragons.DragonsTab).setLightLevel(0.5F).setStepSound(Block.soundTypeStone);
    
            GameRegistry.registerBlock(fireDragonEgg, "fire_dragon_egg");
        }
    }
    

    BlockDragonEgg (fr.MrBlockTNT.Dragons.block)

    package fr.MrBlockTNT.Dragons.block;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import java.util.Random;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockFalling;
    import net.minecraft.block.material.Material;
    import net.minecraft.entity.item.EntityFallingBlock;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.Item;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    
    public class BlockDragonEgg extends Block
    {
        private static final String __OBFID = "CL_00000232";
    
        public BlockDragonEgg()
        {
            super(Material.dragonEgg);
            this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
        }
    
        /**
         * Called whenever the block is added into the world. Args: world, x, y, z
         */
        public void onBlockAdded(World p_149726_1_, int p_149726_2_, int p_149726_3_, int p_149726_4_)
        {
            p_149726_1_.scheduleBlockUpdate(p_149726_2_, p_149726_3_, p_149726_4_, this, this.tickRate(p_149726_1_));
        }
    
        /**
         * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
         * their own) Args: x, y, z, neighbor Block
         */
        public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
        {
            p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_));
        }
    
        /**
         * Ticks the block if it's been scheduled
         */
        public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
        {
            this.func_150018_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
        }
    
        private void func_150018_e(World p_150018_1_, int p_150018_2_, int p_150018_3_, int p_150018_4_)
        {
            if(BlockFalling.func_149831_e(p_150018_1_, p_150018_2_, p_150018_3_ - 1, p_150018_4_) && p_150018_3_ >= 0)
            {
                byte b0 = 32;
    
                if(!BlockFalling.fallInstantly && p_150018_1_.checkChunksExist(p_150018_2_ - b0, p_150018_3_ - b0, p_150018_4_ - b0, p_150018_2_ + b0, p_150018_3_ + b0, p_150018_4_ + b0))
                {
                    EntityFallingBlock entityfallingblock = new EntityFallingBlock(p_150018_1_, (double)((float)p_150018_2_ + 0.5F), (double)((float)p_150018_3_ + 0.5F), (double)((float)p_150018_4_ + 0.5F), this);
                    p_150018_1_.spawnEntityInWorld(entityfallingblock);
                }
                else
                {
                    p_150018_1_.setBlockToAir(p_150018_2_, p_150018_3_, p_150018_4_);
    
                    while(BlockFalling.func_149831_e(p_150018_1_, p_150018_2_, p_150018_3_ - 1, p_150018_4_) && p_150018_3_ > 0)
                    {
                        --p_150018_3_;
                    }
    
                    if(p_150018_3_ > 0)
                    {
                        p_150018_1_.setBlock(p_150018_2_, p_150018_3_, p_150018_4_, this, 0, 2);
                    }
                }
            }
        }
    
        /**
         * Called upon block activation (right click on the block.)
         */
        public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)
        {
            this.func_150019_m(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_);
            return true;
        }
    
        /**
         * Called when a player hits the block. Args: world, x, y, z, player
         */
        public void onBlockClicked(World p_149699_1_, int p_149699_2_, int p_149699_3_, int p_149699_4_, EntityPlayer p_149699_5_)
        {
            this.func_150019_m(p_149699_1_, p_149699_2_, p_149699_3_, p_149699_4_);
        }
    
        private void func_150019_m(World p_150019_1_, int p_150019_2_, int p_150019_3_, int p_150019_4_)
        {
            if(p_150019_1_.getBlock(p_150019_2_, p_150019_3_, p_150019_4_) == this)
            {
                for(int l = 0; l < 1000; ++l)
                {
                    int i1 = p_150019_2_ + p_150019_1_.rand.nextInt(16) - p_150019_1_.rand.nextInt(16);
                    int j1 = p_150019_3_ + p_150019_1_.rand.nextInt(8) - p_150019_1_.rand.nextInt(8);
                    int k1 = p_150019_4_ + p_150019_1_.rand.nextInt(16) - p_150019_1_.rand.nextInt(16);
    
                    if(p_150019_1_.getBlock(i1, j1, k1).getMaterial() == Material.air)
                    {
                        if(!p_150019_1_.isRemote)
                        {
                            p_150019_1_.setBlock(i1, j1, k1, this, p_150019_1_.getBlockMetadata(p_150019_2_, p_150019_3_, p_150019_4_), 2);
                            p_150019_1_.setBlockToAir(p_150019_2_, p_150019_3_, p_150019_4_);
                        }
                        else
                        {
                            short short1 = 128;
    
                            for(int l1 = 0; l1 < short1; ++l1)
                            {
                                double d0 = p_150019_1_.rand.nextDouble();
                                float f = (p_150019_1_.rand.nextFloat() - 0.5F) * 0.2F;
                                float f1 = (p_150019_1_.rand.nextFloat() - 0.5F) * 0.2F;
                                float f2 = (p_150019_1_.rand.nextFloat() - 0.5F) * 0.2F;
                                double d1 = (double)i1 + (double)(p_150019_2_ - i1) * d0 + (p_150019_1_.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
                                double d2 = (double)j1 + (double)(p_150019_3_ - j1) * d0 + p_150019_1_.rand.nextDouble() * 1.0D - 0.5D;
                                double d3 = (double)k1 + (double)(p_150019_4_ - k1) * d0 + (p_150019_1_.rand.nextDouble() - 0.5D) * 1.0D + 0.5D;
                                p_150019_1_.spawnParticle("portal", d1, d2, d3, (double)f, (double)f1, (double)f2);
                            }
                        }
    
                        return;
                    }
                }
            }
        }
    
        /**
         * How many world ticks before ticking
         */
        public int tickRate(World p_149738_1_)
        {
            return 5;
        }
    
        /**
         * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
         * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
         */
        public boolean isOpaqueCube()
        {
            return false;
        }
    
        /**
         * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
         */
        public boolean renderAsNormalBlock()
        {
            return false;
        }
    
        /**
         * Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
         * coordinates. Args: blockAccess, x, y, z, side
         */
        @SideOnly(Side.CLIENT)
        public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_)
        {
            return true;
        }
    
        /**
         * The type of render function that is called for this block
         */
        public int getRenderType()
        {
            return 27;
        }
    
        /**
         * Gets an item for the block being called on. Args: world, x, y, z
         */
        @SideOnly(Side.CLIENT)
        public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
        {
            return Item.getItemById(0);
        }
    }
    

    J'ai beau chercher l'erreur avec dragonEgg (Material.class) mais je ne trouve pas.... 😞

    Un peu d'aide svp ? :huh:



  • Pour commencer, vire :

    private static final String __OBFID = "CL_00000232";
    

    Ensuite, le material de ton block est mal construis (je pense) :

    public BlockDragonEgg()
    {
        super(Material.dragonEgg);
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
    }
    

    Mets plutôt :

    public BlockDragonEgg(Material material)
    {
        super(material);
        this.setBlockBounds(0.0625F, 0.0F, 0.0625F, 0.9375F, 1.0F, 0.9375F);
    }
    

    Du coup, dans ta classe principale, change :

        fireDragonEgg = new BlockDragonEgg()
    

    En :

        fireDragonEgg = new BlockDragonEgg(Material.dragonEgg)
    

  • Moddeurs confirmés Rédacteurs Modérateurs Administrateurs

    Cela ne change strictement rien à la définition du Material. Ensuite, à quoi correspond la ligne 22 de BlockDragonEgg.



  • @zery59 Merci mais ça ne marche toujours pas 😢 (même erreur)

    @Superloup10 La ligne 22 ? C'est une accolade x)
    En fait, le code est totalement copié des classes de Minecraft car si j'utilisait l'originale, le jeu plantait encore à cause de setHardness() et setResistance().


  • Moddeurs confirmés Rédacteurs Modérateurs Administrateurs

    Envois ta class par pastebin.



  • BlockDragonEgg.java :
    http://pastebin.com/YWy0jum2
    Dragons.java :
    http://pastebin.com/WtafMkec


  • Moddeurs confirmés Rédacteurs Administrateurs

    gradlew build
    Et le jar se trouve dans build/libs/ il s'appelle modid-1.0.jar par défaut.

    Si tu prends le fichier comme tu as fait ça ne fonctionne pas.



  • Ah merci ça marche, sujet résolu.


Log in to reply