1.12.2 Problème de Code avec IDEA



  • Bonjour,
    J'ai un problème car IDEA refuse de lancé le jeu car Material.IRON bug :
    Code :

        public void init()
        {
            rainbow_block = new CSMMBlock("rainbow_block", Material.IRON, 5.0f, 30.0f, 2, "pickaxe");
            
    
        }
    
    

    Erreur de IDEA :

    CSMMBlock(java.lang.String, javafx.scene.paint.Material, float, float, int, java.lang.String)' in 'fr.dodo.rainbow.items.CSMMBlock' cannot be applied to '(java.lang.String, net.minecraft.block.material.Material, float, float, int, java.lang.String)
    

    J'ai un autre Problème avec ce constructeur là :

     public CSMMBlock(String name, Material materialV)
        {
            super(materialV);
            setRegistryName(name).setUnlocalizedName(name);
    
            ModBlocks.INSTANCE.getBlocks().add(this);
    
        }
    

    Et IDEA me dit :

    Block(net.minecraft.block.material.Material)' in 'net.minecraft.block.Block' cannot be applied to '(javafx.scene.paint.Material)
    

    Merci de m'aider
    Cordialement Dodo_Report


  • Moddeurs confirmés Rédacteurs Administrateurs

    Bonjour,

    Tu as importé la mauvaise classe Material. (il faut prendre celle du package net.minecraft.block.material).

    Et il va falloir faire plus de recherche avant de demander de l'aide, c'est la dernière fois que je laisse passer une demande dans ce genre ...



  • c'est ce que j'ai fait. regarde :
    text alternatif


  • Moddeurs confirmés Rédacteurs Administrateurs

    Envoies le code complet de ta classe.



  • Voila

    package fr.dodo.rainbow.init;
    
    import fr.dodo.rainbow.items.CSMMBlock;
    import fr.dodo.rainbow.utils.References;
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.block.model.ModelResourceLocation;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.util.ResourceLocation;
    import net.minecraftforge.client.event.ModelRegistryEvent;
    import net.minecraftforge.client.model.ModelLoader;
    import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    
    import java.util.List;
    
    public class ModBlocks {
    
        public static final ModBlocks INSTANCE = new ModBlocks();
    
        public static Block rainbow_block;
    
        private List<Block> blocks;
    
    
        public void init()
        {
            rainbow_block = new CSMMBlock("rainbow_block", Material.IRON, 5.0f, 30.0f, 2, "pickaxe");
            
    
        }
        @SubscribeEvent
        public  void registerModels(ModelRegistryEvent e)
        {
            for(Block b : blocks){
    
                registerModel(b);
    
            }
    
        }
    
        private void registerModel(Block block)
        {
    
    
            ItemBlock rb = new ItemBlock(block);
            rb.setRegistryName(block.getRegistryName());
            GameRegistry.findRegistry(Item.class).register(rb);
    
            ModelLoader.setCustomModelResourceLocation(Item.getItemFromBlock(block),0, new ModelResourceLocation(new ResourceLocation(References.MODID, block.getUnlocalizedName().substring(5)), "inventory"));
    
    
    
        }
    
    
        public List<Block> getBlocks() {
            return blocks;
        }
    }
    
    


  • Je t'ai déjà répondu en mp sur discord, dans ta classe CSMMBlock, dans ton contructeur, tu dois aussi changer le Material par celui de net.minecraft.block.material.Material.
    encore une fois, ce sont les basiques du java.



  • g pas comprit comme ca sur discord mais la g comprit donc mrc



  • J'ai un problème !
    quand je lance mon jeux il crash !

    ---- Minecraft Crash Report ----
    // Daisy, daisy...
    
    Time: 12/7/19 1:59 PM
    Description: Initializing game
    
    java.lang.NullPointerException: Initializing game
    	at fr.dodo.rainbow.items.CSMMBlock.<init>(CSMMBlock.java:13)
    	at fr.dodo.rainbow.items.CSMMBlock.<init>(CSMMBlock.java:19)
    	at fr.dodo.rainbow.items.CSMMBlock.<init>(CSMMBlock.java:27)
    	at fr.dodo.rainbow.init.ModBlocks.init(ModBlocks.java:33)
    	at fr.dodo.rainbow.events.RegisteringEvent.registerBlocks(RegisteringEvent.java:25)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_RegisteringEvent_registerBlocks_Register.invoke(.dynamic)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:740)
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:245)
    	at net.minecraft.client.Minecraft.init(Minecraft.java:513)
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    	at GradleStart.main(GradleStart.java:25)
    
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Thread: Client thread
    Stacktrace:
    	at fr.dodo.rainbow.items.CSMMBlock.<init>(CSMMBlock.java:13)
    	at fr.dodo.rainbow.items.CSMMBlock.<init>(CSMMBlock.java:19)
    	at fr.dodo.rainbow.items.CSMMBlock.<init>(CSMMBlock.java:27)
    	at fr.dodo.rainbow.init.ModBlocks.init(ModBlocks.java:33)
    	at fr.dodo.rainbow.events.RegisteringEvent.registerBlocks(RegisteringEvent.java:25)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_RegisteringEvent_registerBlocks_Register.invoke(.dynamic)
    	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144)
    	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:740)
    	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628)
    	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:245)
    	at net.minecraft.client.Minecraft.init(Minecraft.java:513)
    
    -- Initialization --
    Details:
    Stacktrace:
    	at net.minecraft.client.Minecraft.run(Minecraft.java:421)
    	at net.minecraft.client.main.Main.main(Main.java:118)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
    	at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.lang.reflect.Method.invoke(Method.java:498)
    	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)
    	at GradleStart.main(GradleStart.java:25)
    
    -- System Details --
    Details:
    	Minecraft Version: 1.12.2
    	Operating System: Windows 10 (amd64) version 10.0
    	Java Version: 1.8.0_231, Oracle Corporation
    	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    	Memory: 210108832 bytes (200 MB) / 516947968 bytes (493 MB) up to 1901592576 bytes (1813 MB)
    	JVM Flags: 0 total; 
    	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    	FML: MCP 9.42 Powered by Forge 14.23.4.2705 5 mods loaded, 5 mods active
    	States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
    
    	| State | ID        | Version      | Source                           | Signature |
    	|:----- |:--------- |:------------ |:-------------------------------- |:--------- |
    	| UCH   | minecraft | 1.12.2       | minecraft.jar                    | None      |
    	| UCH   | mcp       | 9.42         | minecraft.jar                    | None      |
    	| UCH   | FML       | 8.0.99.99    | forgeSrc-1.12.2-14.23.4.2705.jar | None      |
    	| UCH   | forge     | 14.23.4.2705 | forgeSrc-1.12.2-14.23.4.2705.jar | None      |
    	| UCH   | rainbow   | Beta 1.0     | MDK.main                         | None      |
    
    	Loaded coremods (and transformers): 
    	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 431.36' Renderer: 'GeForce GTX 1050 Ti/PCIe/SSE2'
    	Launched Version: 1.12.2
    	LWJGL: 2.9.4
    	OpenGL: GeForce GTX 1050 Ti/PCIe/SSE2 GL version 4.6.0 NVIDIA 431.36, NVIDIA Corporation
    	GL Caps: Using GL 1.3 multitexturing.
    Using GL 1.3 texture combiners.
    Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.
    Shaders are available because OpenGL 2.1 is supported.
    VBOs are available because OpenGL 1.5 is supported.
    
    	Using VBOs: Yes
    	Is Modded: Definitely; Client brand changed to 'fml,forge'
    	Type: Client (map_client.txt)
    	Resource Packs: Pack texture
    	Current Language: English (US)
    	Profiler Position: N/A (disabled)
    	CPU: 4x Intel(R) Pentium(R) CPU G4600 @ 3.60GHz
    

    ps : on m'a dit d'initialisé ma list et m'a donné ca : leNomDeList = Lists#newArrayList()
    donc j'ai fait ca mais ca marche pas : blocks = Lists.newArrayList();


  • Moddeurs confirmés Rédacteurs Administrateurs

    Envoies ta classe CSMMBlock


Log in to reply