Aide pour liquide



  • Bonjour à tous
    Je ne voulais pas créer de topic pour cela, mais je bloque…
    Je voudrais créer un liquide, mais aucun tutoriel est en 1.8
    J'ai suivi ces 2 tutos, le 1er, en 1er, et le 2e, eeuuh bref

    Voici mes classes :
    MainClass :::

    package eryah.galratech;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockDynamicLiquid;
    import net.minecraft.block.BlockStaticLiquid;
    import net.minecraft.block.material.Material;
    import net.minecraft.item.Item;
    import net.minecraft.util.ResourceLocation;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fluids.FluidRegistry;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.common.Mod.EventHandler;
    import net.minecraftforge.fml.common.SidedProxy;
    import net.minecraftforge.fml.common.event.FMLInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    import eryah.galratech.blocks.RustyMetalBlock;
    import eryah.galratech.items.GalraTechGlove;
    import eryah.galratech.items.Lens;
    import eryah.galratech.liquids.BlockYourFluid;
    import eryah.galratech.proxy.CommonProxy;
    
    @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
    public class GalraTechMod
    {
    
        @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
        public static CommonProxy proxy;
    
        public static final CreativeTab GalraTab = new CreativeTab("GalraTab");
    
        @Mod.Instance(Reference.MOD_ID)
        public static GalraTechMod instance;
    
        //Déclaration
        //Items
        public static Item galratech_glove;
    
        //Matériaux
        public static Item lens;
    
        //Blocks
    
        //Déco
        public static Block rusty_iron_block;
    
        //Fluids  
        public static Fluid yourFluid;
        public static Block yourFluidBlock;
    
        @EventHandler
        public void preInit(FMLPreInitializationEvent event)
        {
        //UnlocalizedName
            galratech_glove = new GalraTechGlove().setUnlocalizedName("galratech_glove").setCreativeTab(GalraTechMod.GalraTab);
    
            //Items
    
            //Matériaux
            lens = new Lens().setUnlocalizedName("lens").setCreativeTab(GalraTechMod.GalraTab);
    
            //Blocs
    
            //Déco
            rusty_iron_block = new RustyMetalBlock(Material.iron).setUnlocalizedName("rusty_iron_block").setCreativeTab(GalraTechMod.GalraTab);
    
            //Fluids
    
            //Register
    
            //Fluids
               Fluid yourFluid = new Fluid("fluidname").setLuminosity(15).setDensity(40000).setTemperature(310).setViscosity(2500);
               FluidRegistry.registerFluid(yourFluid);
               yourFluidBlock = new BlockYourFluid(yourFluid, Material.water).setBlockName("yourFluid");
               GameRegistry.registerBlock(yourFluidBlock, Reference.MOD_ID + "_" + yourFluidBlock.getUnlocalizedName().substring(5));
               yourFluid.setUnlocalizedName(yourFluidBlock.getUnlocalizedName());
    
            //Items
    
               GameRegistry.registerItem(galratech_glove, "galratech_glove");
    
            //Matériaux
            GameRegistry.registerItem(lens, "lens");
    
            //Blocks
    
            //Déco
               GameRegistry.registerBlock(rusty_iron_block, "rusty_iron_block");
    
            proxy.registerRenders();
        }
    
        @EventHandler
        public void init(FMLInitializationEvent event)
        {
        //Register Texture
        //Blocks
    
        //Déco
        proxy.registerBlockTexture(rusty_iron_block, "rusty_iron_block");
        }
    
        @EventHandler
        public void postInit(FMLPostInitializationEvent event)
        {
    
        }
    
        private static Block getRegisteredBlock(String p_180383_0_)
        {
            return (Block)Block.blockRegistry.getObject(new ResourceLocation(p_180383_0_));
        }
    }
    

    :::

    Block Fluide :::

    package eryah.galratech.liquids;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.util.BlockPos;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.fluids.BlockFluidClassic;
    import net.minecraftforge.fluids.Fluid;
    
    public class BlockYourFluid extends BlockFluidClassic {
    
            public BlockYourFluid(Fluid fluid, Material material) {
                    super(fluid, material);
                    setCreativeTab(CreativeTabs.tabMisc);
            }
    
            @Override
            public boolean canDisplace(IBlockAccess world, BlockPos pos) {
                    if (((Block) world.getBlockState(pos)).getMaterial().isLiquid()) return false;
                    return super.canDisplace(world, pos);
            }
    
            @Override
            public boolean displaceIfPossible(World world, BlockPos pos) {
                    if (((Block) world.getBlockState(pos)).getMaterial().isLiquid()) return false;
                    return super.displaceIfPossible(world, pos);
            }
    
    public Block setBlockName(String string) {
    // TODO Auto-generated method stub
    return null;
    }
    
    }
    

    :::

    CrashReport :::

    
    –-- Minecraft Crash Report ----
    // Oh - I know what I did wrong!
    
    Time: 13/08/15 00:07
    Description: Initializing game
    
    java.lang.NullPointerException: Initializing game
    at eryah.galratech.GalraTechMod.preInit(GalraTechMod.java:84)
    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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537)
    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.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
    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.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:527)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:246)
    at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
    at net.minecraft.client.Minecraft.run(Minecraft.java:356)
    at net.minecraft.client.main.Main.main(Main.java:117)
    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:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
    at GradleStart.main(Unknown Source)
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Stacktrace:
    at eryah.galratech.GalraTechMod.preInit(GalraTechMod.java:84)
    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.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537)
    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.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
    at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
    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.EventSubscriber.handleEvent(EventSubscriber.java:74)
    at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
    at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
    at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
    at com.google.common.eventbus.EventBus.post(EventBus.java:275)
    at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
    at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:527)
    at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:246)
    at net.minecraft.client.Minecraft.startGame(Minecraft.java:446)
    
    -- Initialization --
    Details:
    Stacktrace:
    at net.minecraft.client.Minecraft.run(Minecraft.java:356)
    at net.minecraft.client.main.Main.main(Main.java:117)
    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:135)
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
    at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
    at GradleStart.main(Unknown Source)
    
    -- System Details --
    Details:
    Minecraft Version: 1.8
    Operating System: Windows 8.1 (amd64) version 6.3
    Java Version: 1.8.0_51, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 859242912 bytes (819 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP v9.10 FML v8.99.8.1412 Minecraft Forge 11.14.1.1412 4 mods loaded, 4 mods active
    mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
    FML{8.99.8.1412} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1412.jar) Unloaded->Constructed->Pre-initialized
    Forge{11.14.1.1412} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1412.jar) Unloaded->Constructed->Pre-initialized
    galratech{ALPHA 0.1} [GalraTech] (bin) Unloaded->Constructed->Errored
    Loaded coremods (and transformers): 
    GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.2.12420 Compatibility Profile Context 13.151.0.0' Renderer: 'AMD Radeon HD 8240'
    Launched Version: 1.8
    LWJGL: 2.9.1
    OpenGL: AMD Radeon HD 8240 GL version 4.2.12420 Compatibility Profile Context 13.151.0.0, ATI Technologies Inc.
    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: []
    Current Language: English (US)
    Profiler Position: N/A (disabled)
    
    

    :::

    Je voudrais préciser que c'est le bordel dans les classes, j'ai fait ça a l'arrache, j'ai juste fait les quicks fixes et voila


  • Administrateurs

    Tu as un NullPointerException ligne 84 de ta classe principale.



  • Oui, ça je sais, mais l'erreur est provoquée par quoi ?

    Envoyé de mon SM-G357FZ en utilisant Tapatalk


  • Administrateurs

    Tu as quelques choses de null, le mieux est de séparer en plusieurs lignes pour trouver d'où ça vient.



  • OK je ferais ça demain, mon c est eteint :S
    J'ai regarder un tuto en 1.6 (vidéo) et il y a ub ordre très precit pour register les trucs.

    Envoyé de mon SM-G357FZ en utilisant Tapatalk



  • Déso pour le double post 😕
    C'est bon, j'ai suivi le tuto vidéo en 1.6, j'ai adapté le code en 1.8, et ça fonctionne.
    Enfin, a moitié, enfin, au quart. Je crash quand je pose le block 😕
    Et le bloc n'a pas encore sa texture, et son seau, et sans oublier, son nom, mais ça, je pense que ça va être simple 🙂

    ( Pourquoi as-tu enlever ma yoli présentation robin ? ;( )

    Crash :

    –-- Minecraft Crash Report ----
    // Would you like a cupcake?
    
    Time: 13/08/15 13:57
    Description: Exception while ticking a block
    
    java.lang.ClassCastException: net.minecraft.block.state.BlockState$StateImplementation cannot be cast to net.minecraft.block.Block
    at eryah.galratech.liquids.BlockYourFluid.canDisplace(BlockYourFluid.java:25)
    at net.minecraftforge.fluids.BlockFluidClassic.updateTick(BlockFluidClassic.java:138)
    at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:660)
    at net.minecraft.world.WorldServer.tick(WorldServer.java:226)
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)
    at java.lang.Thread.run(Unknown Source)
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- Head --
    Stacktrace:
    at eryah.galratech.liquids.BlockYourFluid.canDisplace(BlockYourFluid.java:25)
    at net.minecraftforge.fluids.BlockFluidClassic.updateTick(BlockFluidClassic.java:138)
    
    -- Block being ticked --
    Details:
    Block: galratech:galratech_yourFluid_block[level=0]
    Block location: World: (598,4,-30), Chunk: (at 6,0,2 in 37,-2; contains blocks 592,0,-32 to 607,255,-17), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)
    Stacktrace:
    at net.minecraft.world.WorldServer.tickUpdates(WorldServer.java:660)
    at net.minecraft.world.WorldServer.tick(WorldServer.java:226)
    
    – Affected level --
    Details:
    Level name: GalraTech Structures
    All players: 1 total; [EntityPlayerMP['Eryah'/144, l='GalraTech Structures', x=600,72, y=4,00, z=-30,96]]
    Chunk stats: ServerChunkCache: 305 Drop: 0
    Level seed: 3092709139775028757
    Level generator: ID 01 - flat, ver 0\. Features enabled: false
    Level generator options: 3;minecraft:bedrock,2*minecraft:dirt,minecraft:grass;1;village
    Level spawn location: 619,00,4,00,-16,00 - World: (619,4,-16), Chunk: (at 11,0,0 in 38,-1; contains blocks 608,0,-16 to 623,255,-1), Region: (1,-1; contains chunks 32,-32 to 63,-1, blocks 512,0,-512 to 1023,255,-1)
    Level time: 110221 game time, 1056 day time
    Level dimension: 0
    Level storage version: 0x04ABD - Anvil
    Level weather: Rain time: 602 (now: false), thunder time: 110155 (now: false)
    Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true
    Stacktrace:
    at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:763)
    at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:669)
    at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:171)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:540)
    at java.lang.Thread.run(Unknown Source)
    
    – System Details --
    Details:
    Minecraft Version: 1.8
    Operating System: Windows 8.1 (amd64) version 6.3
    Java Version: 1.8.0_51, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 826295736 bytes (788 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)
    JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    FML: MCP v9.10 FML v8.99.8.1412 Minecraft Forge 11.14.1.1412 4 mods loaded, 4 mods active
    mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    FML{8.99.8.1412} [Forge Mod Loader] (forgeSrc-1.8-11.14.1.1412.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Forge{11.14.1.1412} [Minecraft Forge] (forgeSrc-1.8-11.14.1.1412.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    galratech{ALPHA 0.1} [GalraTech] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Loaded coremods (and transformers):
    GL info: ~~ERROR~~ RuntimeException: No OpenGL context found in the current thread.
    Profiler Position: N/A (disabled)
    Player Count: 1 / 8; [EntityPlayerMP['Eryah'/144, l='GalraTech Structures', x=600,72, y=4,00, z=-30,96]]
    Type: Integrated Server (map_client.txt)
    Is Modded: Definitely; Client brand changed to 'fml,forge
    

    Block

    package eryah.galratech.liquids;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.util.BlockPos;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.fluids.BlockFluidClassic;
    import net.minecraftforge.fluids.Fluid;
    import eryah.galratech.GalraTechMod;
    
    public class BlockYourFluid extends BlockFluidClassic {
    
            public BlockYourFluid(Fluid fluid, Material material) {
                    super(fluid, GalraTechMod.materialAcid);
                    setCreativeTab(CreativeTabs.tabMisc);
            }
    
            @Override
            public boolean canDisplace(IBlockAccess world, BlockPos pos) {
                    if (((Block) world.getBlockState(pos)).getMaterial().isLiquid()) return false;
                    return super.canDisplace(world, pos);
            }
    
            @Override
            public boolean displaceIfPossible(World world, BlockPos pos) {
                    if (((Block) world.getBlockState(pos)).getMaterial().isLiquid()) return false;
                    return super.displaceIfPossible(world, pos);
            }
    
    }
    


  • @'Crash Report':

    java.lang.ClassCastException: net.minecraft.block.state.BlockState$StateImplementation cannot be cast to net.minecraft.block.Block

    –> Tu a un problème avec une fonction de cast

    @'Crash Report':

    at eryah.galratech.liquids.BlockYourFluid.canDisplace(BlockYourFluid.java:25)

    –> Tu a l'erreur a la ligne 25.

    @'Ton code (L25)':

    if (((Block) world.getBlockState(pos)).getMaterial().isLiquid()) return false;

    –> ton ((Block) world.getBlockState(pos)) ne fonctionne pas

    BlockState une classe différente de Block. Tu ne peu donc pas la casté comme ca, en revanche, tu peu ajouter ".getBlock()" pour obtenir le block. ta condition devient alors :
    if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;

    p.s : tu aura la même erreur a la ligne 31 si tu ne la modifie pas aussi



  • Merci beaucoup 🙂
    j'avais déja régler le problème du crash, et m'appretait a faire un edit du message, car la, le bloc ne se pose pas


  • Administrateurs

    Tu as mit quoi à la place de if (((Block) world.getBlockState(pos)).getMaterial().isLiquid()) return false; ?
    Et j'ai retiré les barres textes car ça foutait la merde mélangé avec les balises codes et spoiler.



  • j'ai mis ce qu'a mis Jodge, mais avant j'ai retiré .getMaterial().isLiquid() , et j'ai mis le quick fix ( != null )Oui c'est con, mais je voulais essayer


  • Administrateurs

    Je ne vois pas ce qui peut causer problème, envoie tout le code complet.



  • MainClass

    package eryah.galratech;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.MapColor;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.material.MaterialLiquid;
    import net.minecraft.item.Item;
    import net.minecraft.util.ResourceLocation;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fluids.FluidRegistry;
    import net.minecraftforge.fml.common.Mod;
    import net.minecraftforge.fml.common.Mod.EventHandler;
    import net.minecraftforge.fml.common.SidedProxy;
    import net.minecraftforge.fml.common.event.FMLInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
    import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
    import net.minecraftforge.fml.common.registry.GameRegistry;
    import eryah.galratech.blocks.RustyMetalBlock;
    import eryah.galratech.items.GalraTechGlove;
    import eryah.galratech.items.Lens;
    import eryah.galratech.liquids.GaloraidAcidBlock;
    import eryah.galratech.proxy.CommonProxy;
    
    @Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
    public class GalraTechMod
    {
    
    @SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
    public static CommonProxy proxy;
    
    public static final CreativeTab GalraTab = new CreativeTab("GalraTab");
    
    @Mod.Instance(Reference.MOD_ID)
    public static GalraTechMod instance;
    
    //Déclaration
    
    //Items
    public static Item galratech_glove;
    
    //Matériaux
    public static Item lens;
    
    //Blocks
    
    //Déco
    public static Block rusty_iron_block;
    
    //Fluids
    public static Fluid galor_acid;
    public static Block galor_acid_block;
    
    //Matériaux
    //Liquids
    public static Material materialGalorAcid;
    
    @EventHandler
    public void preInit(FMLPreInitializationEvent event)
    {
    
    galor_acid = new Fluid("galor_acid").setLuminosity(15).setDensity(40000).setTemperature(310).setViscosity(2500);
    
    FluidRegistry.registerFluid(galor_acid);
    
    materialGalorAcid = new MaterialLiquid(MapColor.emeraldColor);
    
    galor_acid_block = new GaloraidAcidBlock(galor_acid, materialGalorAcid).setUnlocalizedName("galor_acid");
    
    galor_acid.setUnlocalizedName(galor_acid.getUnlocalizedName());
    
    GameRegistry.registerBlock(galor_acid_block, Reference.MOD_ID + "_" + galor_acid.getUnlocalizedName().substring(5));
    
    //UnlocalizedName
    galratech_glove = new GalraTechGlove().setUnlocalizedName("galratech_glove").setCreativeTab(GalraTechMod.GalraTab);
    
    //Items
    
    //Matériaux
    lens = new Lens().setUnlocalizedName("lens").setCreativeTab(GalraTechMod.GalraTab);
    
    //Blocs
    
    //Déco
    rusty_iron_block = new RustyMetalBlock(Material.iron).setUnlocalizedName("rusty_iron_block").setCreativeTab(GalraTechMod.GalraTab);
    
    //Fluids
    
    //Register
    
    //Fluids
    
    //Items
    
    GameRegistry.registerItem(galratech_glove, "galratech_glove");
    
    //Matériaux
    GameRegistry.registerItem(lens, "lens");
    
    //Blocks
    
    //Déco
    GameRegistry.registerBlock(rusty_iron_block, "rusty_iron_block");
    
    proxy.registerRenders();
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    //Register Texture
    //Blocks
    
    //Déco
    proxy.registerBlockTexture(rusty_iron_block, "rusty_iron_block");
    }
    
    @EventHandler
    public void postInit(FMLPostInitializationEvent event)
    {
    
    }
    
    private static Block getRegisteredBlock(String p_180383_0_)
    {
    return (Block)Block.blockRegistry.getObject(new ResourceLocation(p_180383_0_));
    }
    }
    

    Block

    package eryah.galratech.liquids;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.util.BlockPos;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.fluids.BlockFluidClassic;
    import net.minecraftforge.fluids.Fluid;
    import eryah.galratech.GalraTechMod;
    
    public class GaloraidAcidBlock extends BlockFluidClassic {
    
    public GaloraidAcidBlock(Fluid fluid, Material material) {
    super(fluid, GalraTechMod.materialGalorAcid);
    setCreativeTab(CreativeTabs.tabMisc);
    }
    
    @Override
    public boolean canDisplace(IBlockAccess world, BlockPos pos) {
    if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
    return super.canDisplace(world, pos);
    }
    
    @Override
    public boolean displaceIfPossible(World world, BlockPos pos) {
    if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
    return super.displaceIfPossible(world, pos);
    }
    
    }
    

  • Administrateurs

    Et si tu fais un setBlock ça fonctionne ?



  • Alors désolé, je me suis rendu compte que c'est juste que le fluide est invisible
    Je l'ai vu quand la nuit est tombé sur mon monde, et que de la lumière sortait de nulle part, c'était mon liquide, qui emet de la lumière donc, voila, désolé…
    Je pensais que si un liquide n'a pas de texture, se sera le bloc moche, mais non, il est invisible.
    Bn, maintenant je vais tenter d'appliquer la texture, ce qui me parrait super dur, vu que le bloc n'a aps de blockstates, juste un model



  • Bon, je galère énormément avec le rendre du fluide…
    Entre le crash dans crash report lors du world load, et le fluide invisible...
    Personne ne sait comment render un fluide en 1.8 ?

    Envoyé de mon SM-G357FZ en utilisant Tapatalk



  • Et le code de l'eau/lave ?



  • Bon, alors j'ai pris le code de l'eau/lave (BlockLiquid) qui est très mal foutue, j'ai l'impression, ou bien protégée… Mais la...
    J'ai copier les choses dont j'avais besoin, et ma classe resemble donc cela

    package eryah.galratech.liquids;
    
    import java.util.Iterator;
    import java.util.Random;
    
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockDynamicLiquid;
    import net.minecraft.block.BlockStaticLiquid;
    import net.minecraft.block.material.Material;
    import net.minecraft.block.properties.IProperty;
    import net.minecraft.block.properties.PropertyInteger;
    import net.minecraft.block.state.BlockState;
    import net.minecraft.block.state.IBlockState;
    import net.minecraft.client.Minecraft;
    import net.minecraft.client.renderer.WorldRenderer;
    import net.minecraft.client.renderer.texture.TextureAtlasSprite;
    import net.minecraft.client.renderer.texture.TextureMap;
    import net.minecraft.client.resources.model.IBakedModel;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.Entity;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.Item;
    import net.minecraft.util.AxisAlignedBB;
    import net.minecraft.util.BlockPos;
    import net.minecraft.util.EnumFacing;
    import net.minecraft.util.EnumParticleTypes;
    import net.minecraft.util.EnumWorldBlockLayer;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.Vec3;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    import net.minecraftforge.fluids.BlockFluidClassic;
    import net.minecraftforge.fluids.Fluid;
    import net.minecraftforge.fml.relauncher.Side;
    import net.minecraftforge.fml.relauncher.SideOnly;
    import eryah.galratech.GalraTechMod;
    
    public class GaloraidAcidBlock extends BlockFluidClassic {
    
    public static final PropertyInteger LEVEL = PropertyInteger.create("level", 0, 15);
    
    public GaloraidAcidBlock(Fluid fluid, Material material) {
    super(fluid, GalraTechMod.materialGalorAcid);
    setCreativeTab(CreativeTabs.tabMisc);
    this.setDefaultState(this.blockState.getBaseState().withProperty(LEVEL, Integer.valueOf(0)));
    }
    
    @Override
    public boolean canDisplace(IBlockAccess world, BlockPos pos) {
    if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
    return super.canDisplace(world, pos);
    }
    
    @Override
    public boolean displaceIfPossible(World world, BlockPos pos) {
    if (world.getBlockState(pos).getBlock().getMaterial().isLiquid()) return false;
    return super.displaceIfPossible(world, pos);
    }
    
    @Override
    public int getRenderType() {
    // TODO Auto-generated method stub
    return 1;
    }
    
    protected int getLevel(IBlockAccess worldIn, BlockPos pos)
    {
    return worldIn.getBlockState(pos).getBlock().getMaterial() == this.blockMaterial ? ((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() : -1;
    }
    
    protected int getEffectiveFlowDecay(IBlockAccess worldIn, BlockPos pos)
    {
    int i = this.getLevel(worldIn, pos);
    return i >= 8 ? 0 : i;
    }
    
    public boolean isFullCube()
    {
    return false;
    }
    
    public boolean isOpaqueCube()
    {
    return false;
    }
    
    public boolean canCollideCheck(IBlockState state, boolean hitIfLiquid)
    {
    return hitIfLiquid && ((Integer)state.getValue(LEVEL)).intValue() == 0;
    }
    
    @SideOnly(Side.CLIENT)
    public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
    {
    return worldIn.getBlockState(pos).getBlock().getMaterial() == this.blockMaterial ? false : (side == EnumFacing.UP ? true : super.shouldSideBeRendered(worldIn, pos, side));
    }
    
    public AxisAlignedBB getCollisionBoundingBox(World worldIn, BlockPos pos, IBlockState state)
    {
    return null;
    }
    
    @SideOnly(Side.CLIENT)
    public boolean func_176364_g(IBlockAccess p_176364_1_, BlockPos p_176364_2_)
    {
    for (int i = -1; i <= 1; ++i)
    {
    for (int j = -1; j <= 1; ++j)
    {
    IBlockState iblockstate = p_176364_1_.getBlockState(p_176364_2_.add(i, 0, j));
    Block block = iblockstate.getBlock();
    Material material = block.getMaterial();
    
    if (material != this.blockMaterial && !block.isFullBlock())
    {
    return true;
    }
    }
    }
    
    return false;
    }
    
    public Item getItemDropped(IBlockState state, Random rand, int fortune)
    {
    return null;
    }
    
    /**
    * Returns the quantity of items to drop on block destruction.
    */
    public int quantityDropped(Random random)
    {
    return 0;
    }
    
    public Vec3 getFlowVector(IBlockAccess worldIn, BlockPos pos)
    {
    Vec3 vec3 = new Vec3(0.0D, 0.0D, 0.0D);
    int i = this.getEffectiveFlowDecay(worldIn, pos);
    Iterator iterator = EnumFacing.Plane.HORIZONTAL.iterator();
    EnumFacing enumfacing;
    BlockPos blockpos1;
    
    while (iterator.hasNext())
    {
    enumfacing = (EnumFacing)iterator.next();
    blockpos1 = pos.offset(enumfacing);
    int j = this.getEffectiveFlowDecay(worldIn, blockpos1);
    int k;
    
    if (j < 0)
    {
    if (!worldIn.getBlockState(blockpos1).getBlock().getMaterial().blocksMovement())
    {
    j = this.getEffectiveFlowDecay(worldIn, blockpos1.down());
    
    if (j >= 0)
    {
    k = j - (i - 8);
    vec3 = vec3.addVector((double)((blockpos1.getX() - pos.getX()) * k), (double)((blockpos1.getY() - pos.getY()) * k), (double)((blockpos1.getZ() - pos.getZ()) * k));
    }
    }
    }
    else if (j >= 0)
    {
    k = j - i;
    vec3 = vec3.addVector((double)((blockpos1.getX() - pos.getX()) * k), (double)((blockpos1.getY() - pos.getY()) * k), (double)((blockpos1.getZ() - pos.getZ()) * k));
    }
    }
    
    if (((Integer)worldIn.getBlockState(pos).getValue(LEVEL)).intValue() >= 8)
    {
    iterator = EnumFacing.Plane.HORIZONTAL.iterator();
    
    while (iterator.hasNext())
    {
    enumfacing = (EnumFacing)iterator.next();
    blockpos1 = pos.offset(enumfacing);
    
    if (this.isBlockSolid(worldIn, blockpos1, enumfacing) || this.isBlockSolid(worldIn, blockpos1.up(), enumfacing))
    {
    vec3 = vec3.normalize().addVector(0.0D, -6.0D, 0.0D);
    break;
    }
    }
    }
    
    return vec3.normalize();
    }
    
    public Vec3 modifyAcceleration(World worldIn, BlockPos pos, Entity entityIn, Vec3 motion)
    {
    return motion.add(this.getFlowVector(worldIn, pos));
    }
    
    public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
    {
    this.checkForMixing(worldIn, pos, state);
    }
    
    @SideOnly(Side.CLIENT)
    public static double getFlowDirection(IBlockAccess worldIn, BlockPos pos, Material materialIn)
    {
    Vec3 vec3 = getFlowingBlock(materialIn).getFlowVector(worldIn, pos);
    return vec3.xCoord == 0.0D && vec3.zCoord == 0.0D ? -1000.0D : Math.atan2(vec3.zCoord, vec3.xCoord) - (Math.PI / 2D);
    }
    
    public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
    {
    this.checkForMixing(worldIn, pos, state);
    }
    
    public boolean checkForMixing(World worldIn, BlockPos pos, IBlockState state)
    {
    if (this.blockMaterial == Material.lava)
    {
    boolean flag = false;
    EnumFacing[] aenumfacing = EnumFacing.values();
    int i = aenumfacing.length;
    
    for (int j = 0; j < i; ++j)
    {
    EnumFacing enumfacing = aenumfacing[j];
    
    if (enumfacing != EnumFacing.DOWN && worldIn.getBlockState(pos.offset(enumfacing)).getBlock().getMaterial() == Material.water)
    {
    flag = true;
    break;
    }
    }
    
    if (flag)
    {
    Integer integer = (Integer)state.getValue(LEVEL);
    
    if (integer.intValue() == 0)
    {
    worldIn.setBlockState(pos, Blocks.obsidian.getDefaultState());
    this.triggerMixEffects(worldIn, pos);
    return true;
    }
    
    if (integer.intValue() <= 4)
    {
    worldIn.setBlockState(pos, Blocks.cobblestone.getDefaultState());
    this.triggerMixEffects(worldIn, pos);
    return true;
    }
    }
    }
    
    return false;
    }
    
    protected void triggerMixEffects(World worldIn, BlockPos pos)
    {
    double d0 = (double)pos.getX();
    double d1 = (double)pos.getY();
    double d2 = (double)pos.getZ();
    worldIn.playSoundEffect(d0 + 0.5D, d1 + 0.5D, d2 + 0.5D, "random.fizz", 0.5F, 2.6F + (worldIn.rand.nextFloat() - worldIn.rand.nextFloat()) * 0.8F);
    
    for (int i = 0; i < 8; ++i)
    {
    worldIn.spawnParticle(EnumParticleTypes.SMOKE_LARGE, d0 + Math.random(), d1 + 1.2D, d2 + Math.random(), 0.0D, 0.0D, 0.0D, new int[0]);
    }
    }
    
    /**
    * Convert the given metadata into a BlockState for this Block
    */
    public IBlockState getStateFromMeta(int meta)
    {
    return this.getDefaultState().withProperty(LEVEL, Integer.valueOf(meta));
    }
    
    /**
    * Convert the BlockState into the correct metadata value
    */
    public int getMetaFromState(IBlockState state)
    {
    return ((Integer)state.getValue(LEVEL)).intValue();
    }
    
    protected BlockState createBlockState()
    {
    return new BlockState(this, new IProperty[] {LEVEL});
    }
    
    public static BlockDynamicLiquid getFlowingBlock(Material materialIn)
    {
    if(materialIn == GalraTechMod.materialGalorAcid) {
    return GalraTechMod.galor_acid_flowing;
    }
    else
    {
    throw new IllegalArgumentException("Invalid material");
    }
    }
    
    public static BlockStaticLiquid getStaticBlock(Material materialIn)
    {
    if(materialIn == GalraTechMod.materialGalorAcid) {
    return GalraTechMod.galor_acid_static;
    }
    else
    {
    throw new IllegalArgumentException("Invalid material");
    }
    }
    }
    

    Et j'ai une erreur ici

    @SideOnly(Side.CLIENT)
    public static double getFlowDirection(IBlockAccess worldIn, BlockPos pos, Material materialIn)
    {
    Vec3 vec3 = getFlowingBlock(materialIn).***getFlowVector***(worldIn, pos);
    return vec3.xCoord == 0.0D && vec3.zCoord == 0.0D ? -1000.0D : Math.atan2(vec3.zCoord, vec3.xCoord) - (Math.PI / 2D);
    }
    

    The method getFlowVector(IBlockAccess, BlockPos) from the type BlockLiquid is not visible
    Que faire ?



  • C'est une méthode statique, donc tu peux appeler celui de l'eau


Log in to reply