Jump to content

[1.7.2] How To Create A Fluid


BungeeTheCookie

Recommended Posts

Hello people of the Forge community! I am stumped with creating a custom fluid. I was reading up on the "Creating a Fluid 1.7.2" resource on the Forge wiki, but when I got to creating the block class and registering the textures, I just got mixed up, some classes didn't exist, etc. Can anyone help me with this?

 

Here is my current code for registering liquids:

 

    public static void registerLiquid(String fluidName, String fluidBlockName, String bucketName, Block fluidBlock, ItemBucket bucket, int brightness, int density, int viscosity, boolean isGaseous){
        Fluid fluid = new Fluid(fluidName);
        fluid.setLuminosity(brightness);
        fluid.setDensity(density);
        fluid.setViscosity(viscosity);
        fluid.setGaseous(isGaseous);
        FluidRegistry.registerFluid(fluid);
        GameRegistry.registerBlock(fluidBlock, fluidBlockName);
        bucket.setContainerItem(Items.bucket);
        GameRegistry.registerItem(bucket, bucketName);
        FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(fluidName, FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucket), new ItemStack(Items.bucket));
        BucketHandler.INSTANCE.buckets.put(fluidBlock, bucket);
    }

 

I also have the eventbus registered in the FMLPreInitilizationEvent, etc.

 

Please help me! Tell me if there is anything wrong with my code by the way. Can someone just provide me some code, a list of steps, or a link to a resource (or video) that actually works? Any and all help is appreciated! Thanks!

Link to comment
Share on other sites

I am now trying to help myself, but I am getting a NullPointerException. Is it because the textures are not registered, because I still have no clue how to register the textures.

 

Here is the error:

[19:16:18] [Client thread/ERROR] [FML]: Caught exception from ProjectOP
java.lang.NullPointerException
at net.minecraftforge.fluids.FluidRegistry.getFluidID(FluidRegistry.java:119) ~[FluidRegistry.class:?]
at net.minecraftforge.fluids.Fluid.getID(Fluid.java:177) ~[Fluid.class:?]
at net.minecraftforge.fluids.FluidStack.<init>(FluidStack.java:27) ~[FluidStack.class:?]
at net.minecraftforge.fluids.BlockFluidClassic.<init>(BlockFluidClassic.java:28) ~[blockFluidClassic.class:?]
at bungeecookie.ProjectOP.common.fluids.FluidMilk.<init>(FluidMilk.java:19) ~[FluidMilk.class:?]
at bungeecookie.ProjectOP.common.register.LiquidRegister.main(LiquidRegister.java:18) ~[LiquidRegister.class:?]
at bungeecookie.ProjectOP.common.ProjectOPMod.preInit(ProjectOPMod.java:33) ~[ProjectOPMod.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:536) ~[FMLModContainer.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) ~[guava-15.0.jar:?]
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) ~[guava-15.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) ~[guava-15.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) ~[guava-15.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:267) ~[guava-15.0.jar:?]
at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:209) ~[LoadController.class:?]
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188) ~[LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74) ~[guava-15.0.jar:?]
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:47) ~[guava-15.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:314) ~[guava-15.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:296) ~[guava-15.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:267) ~[guava-15.0.jar:?]
at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
at cpw.mods.fml.common.Loader.loadMods(Loader.java:495) [Loader.class:?]
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:564) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:934) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:112) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134) [launchwrapper-1.9.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.9.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_25]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_25]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_25]
at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_25]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120) [idea_rt.jar:?]
---- Minecraft Crash Report ----
// I blame Dinnerbone.

Time: 3/7/14 7:16 PM
Description: Initializing game

java.lang.NullPointerException: Initializing game
at net.minecraftforge.fluids.FluidRegistry.getFluidID(FluidRegistry.java:119)
at net.minecraftforge.fluids.Fluid.getID(Fluid.java:177)
at net.minecraftforge.fluids.FluidStack.<init>(FluidStack.java:27)
at net.minecraftforge.fluids.BlockFluidClassic.<init>(BlockFluidClassic.java:28)
at bungeecookie.ProjectOP.common.fluids.FluidMilk.<init>(FluidMilk.java:19)
at bungeecookie.ProjectOP.common.register.LiquidRegister.main(LiquidRegister.java:18)
at bungeecookie.ProjectOP.common.ProjectOPMod.preInit(ProjectOPMod.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:536)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:495)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:564)
at net.minecraft.client.Minecraft.run(Minecraft.java:934)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Stacktrace:
at net.minecraftforge.fluids.FluidRegistry.getFluidID(FluidRegistry.java:119)
at net.minecraftforge.fluids.Fluid.getID(Fluid.java:177)
at net.minecraftforge.fluids.FluidStack.<init>(FluidStack.java:27)
at net.minecraftforge.fluids.BlockFluidClassic.<init>(BlockFluidClassic.java:28)
at bungeecookie.ProjectOP.common.fluids.FluidMilk.<init>(FluidMilk.java:19)
at bungeecookie.ProjectOP.common.register.LiquidRegister.main(LiquidRegister.java:18)
at bungeecookie.ProjectOP.common.ProjectOPMod.preInit(ProjectOPMod.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:536)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:209)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:188)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
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:119)
at cpw.mods.fml.common.Loader.loadMods(Loader.java:495)
at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:201)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:564)

-- Initialization --
Details:
Stacktrace:
at net.minecraft.client.Minecraft.run(Minecraft.java:934)
at net.minecraft.client.main.Main.main(Main.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

-- System Details --
Details:
Minecraft Version: 1.7.2
Operating System: Windows 8 (amd64) version 6.2
Java Version: 1.7.0_25, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 739636040 bytes (705 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.01-pre FML v7.2.125.1039 Minecraft Forge 10.12.0.1039 4 mods loaded, 4 mods active
mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized
FML{7.2.125.1039} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.0.1039.jar) Unloaded->Constructed->Pre-initialized
Forge{10.12.0.1039} [Minecraft Forge] (forgeSrc-1.7.2-10.12.0.1039.jar) Unloaded->Constructed->Pre-initialized
ProjectOP{Alpha v0.0.0 for Minecraft 1.7.2} [Project: OP] (ProjectOP) Unloaded->Constructed->Errored
Launched Version: 1.7
LWJGL: 2.9.0
OpenGL: Intel(R) HD Graphics 4000 GL version 4.0.0 - Build 9.17.10.2849, Intel
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)
Vec3 Pool Size: ~~ERROR~~ NullPointerException: null
Anisotropic Filtering: Off (1)
#@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Elizabeth\Desktop\Minecraft Modding\Forge\ProjectOP\eclipse\.\crash-reports\crash-2014-03-07_19.16.18-client.txt

 

And Here are my classes:

public class LiquidRegister {

    public static Fluid milk = new Fluid("milk");

    public static void main(FMLPreInitializationEvent event){
        registerLiquid(milk, new FluidMilk(milk, Material.water, ProjectOPTabs.miscellaneous), null, "fluidMilk", null, 0, 10, 10, false);
    }

    public static void registerLiquid(Fluid fluid, Block fluidBlock, ItemBucket bucket, String fluidBlockName, String bucketName,  int brightness, int density, int viscosity, boolean isGaseous){
        fluid.setLuminosity(brightness);
        fluid.setDensity(density);
        fluid.setViscosity(viscosity);
        fluid.setGaseous(isGaseous);
        FluidRegistry.registerFluid(fluid);
        GameRegistry.registerBlock(fluidBlock, fluidBlockName);
        //bucket.setContainerItem(Items.bucket);
        //GameRegistry.registerItem(bucket, bucketName);
        //FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack(fluid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucket), new ItemStack(Items.bucket));
        //BucketHandler.INSTANCE.buckets.put(fluidBlock, bucket);
    }
}

 

public class FluidMilk extends BlockFluidClassic {

@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;

    public FluidMilk(Fluid fluid, Material material, CreativeTabs tab){
        super(fluid, material);
        this.setBlockName("fluidMilk");
        this.setCreativeTab(tab);
    }
}

Link to comment
Share on other sites

  • 2 months later...

Sorry to revive an old thread, but did anyone figure it out? I am having the exact same problem. The registerIcons() function isn't being called, so my fluid just shows up without a texture.

Here's my code:

 

 

package Other;

 

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.IIcon;

import net.minecraftforge.fluids.BlockFluidClassic;

import net.minecraftforge.fluids.Fluid;

 

public class BlockFluidMilk extends BlockFluidClassic{

public static IIcon milkFlowingIcon;

  public static IIcon milkStillIcon;

 

public BlockFluidMilk(Fluid fluid, Material material) {

super(fluid, material);

setCreativeTab(CreativeTabs.tabRedstone);

}

 

  public void registerIcons(IIconRegister iconRegister)

  {

    cacaStillIcon = iconRegister.registerIcon("supertnt:milk_still");

    cacaFlowingIcon = iconRegister.registerIcon("supertnt:milk_flow");

  }

 

  public IIcon func_149691_a(int side, int meta)

  {

    return (side != 0) && (side != 1) ? milkFlowingIcon : milkStillIcon;

  }

}

 

 

 

 

Link to comment
Share on other sites

I have done as the guide said, I still crash...

 

Here's the crash-log

 

 

 

 

---- Minecraft Crash Report ----

// Surprise! Haha. Well, this is awkward.

 

Time: 07/06/14 19.21

Description: Initializing game

 

java.lang.ExceptionInInitializerError

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:270)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:420)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

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(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

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.loadMods(Loader.java:491)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)

at net.minecraft.client.Minecraft.run(Minecraft.java:892)

at net.minecraft.client.main.Main.main(Main.java:112)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

Caused by: java.lang.NullPointerException

at net.minecraftforge.fluids.FluidRegistry.getFluidID(FluidRegistry.java:119)

at net.minecraftforge.fluids.Fluid.getID(Fluid.java:177)

at net.minecraftforge.fluids.FluidStack.<init>(FluidStack.java:27)

at net.minecraftforge.fluids.BlockFluidClassic.<init>(BlockFluidClassic.java:28)

at com.dvd.basic.fluids.BasicFluidBlock.<init>(BasicFluidBlock.java:24)

at com.dvd.basic.Basic.<clinit>(Basic.java:118)

... 35 more

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at java.lang.Class.forName0(Native Method)

at java.lang.Class.forName(Class.java:270)

at cpw.mods.fml.common.FMLModContainer.constructMod(FMLModContainer.java:420)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

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(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

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.loadMods(Loader.java:491)

at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:204)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)

 

-- Initialization --

Details:

Stacktrace:

at net.minecraft.client.Minecraft.run(Minecraft.java:892)

at net.minecraft.client.main.Main.main(Main.java:112)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:134)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

 

-- System Details --

Details:

Minecraft Version: 1.7.2

Operating System: Mac OS X (x86_64) version 10.7.5

Java Version: 1.7.0_51, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 901539224 bytes (859 MB) / 1056309248 bytes (1007 MB) up to 1056309248 bytes (1007 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.03 FML v7.2.207.1103 Minecraft Forge 10.12.1.1103 4 mods loaded, 4 mods active

mcp{9.03} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed

FML{7.2.207.1103} [Forge Mod Loader] (forgeSrc-1.7.2-10.12.1.1103.jar) Unloaded->Constructed

Forge{10.12.1.1103} [Minecraft Forge] (forgeSrc-1.7.2-10.12.1.1103.jar) Unloaded->Constructed

basic{1.0} [basic Mod] (bin) Unloaded

Launched Version: 1.6

LWJGL: 2.9.1

OpenGL: NVIDIA GeForce 9400M OpenGL Engine GL version 2.1 NVIDIA-7.32.12, NVIDIA Corporation

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)

Vec3 Pool Size: ~~ERROR~~ NullPointerException: null

Anisotropic Filtering: Off (1)

 

 

 

 

Here's my Main Class

 

 

 

...

// Fluid

public static Fluid basicFluid = new Fluid("fluidname").setLuminosity(10).setTemperature(10)

.setViscosity(2500).setUnlocalizedName("basicFluid");

 

public static Block basicFluidBlock = new BasicFluidBlock(basicFluid, Material.water)

.setBlockName("basicFluid");

...

 

GameRegistry.registerBlock(basicFluidBlock, "basicFluid");

FluidRegistry.registerFluid(basicFluid);

 

 

 

 

 

 

package com.dvd.basic.fluids;

 

import com.dvd.basic.Basic;

 

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.util.IIcon;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraftforge.fluids.BlockFluidClassic;

import net.minecraftforge.fluids.Fluid;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

 

public class BasicFluidBlock extends BlockFluidClassic{

 

@SideOnly(Side.CLIENT)

    protected IIcon stillIcon;

    @SideOnly(Side.CLIENT)

    protected IIcon flowingIcon;

   

    public BasicFluidBlock(Fluid fluid, Material material) {

            super(fluid, material);

            setCreativeTab(CreativeTabs.tabMisc);

    }

   

    @Override

    public IIcon getIcon(int side, int meta) {

            return (side == 0 || side == 1)? stillIcon : flowingIcon;

    }

   

    @SideOnly(Side.CLIENT)

    @Override

    public void registerBlockIcons(IIconRegister register) {

            stillIcon = register.registerIcon(Basic.MODID+":fluidStill");

            flowingIcon = register.registerIcon(Basic.MODID+":fluidFlowing");

    }

   

    @Override

    public boolean canDisplace(IBlockAccess world, int x, int y, int z) {

            if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;

            return super.canDisplace(world, x, y, z);

    }

   

    @Override

    public boolean displaceIfPossible(World world, int x, int y, int z) {

            if (world.getBlock(x,  y,  z).getMaterial().isLiquid()) return false;

            return super.displaceIfPossible(world, x, y, z);

    }

}

 

 

 

 

If I don't initialize the BasicFLuidBlock the game starts normally.

 

I can't find the issue, thanks for the help.

 

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Link to comment
Share on other sites

Thanks, now it's working!!!

 

I tried to make the bucket, as the guide said and it's not working. Instead of getting a bucket filled of my fluid, I get the one filled with the material of that fluid block (e.g. Block basicFluidBlock = new BasicFluidBlock(basicFluid, Material.water) when I pick it up with the bucket I get a water bucket)

 

Here's the Main Class

 

 

 

 

...

 

              public static Fluid basicFluid = new Fluid("basicFluid").setLuminosity(10).setTemperature(10)

.setViscosity(2500).setGaseous(true).setUnlocalizedName("basicFluid");

 

...

...

              Block basicFluidBlock = new BasicFluidBlock(basicFluid, Material.water)

.setBlockName("basicFluidBlock");

 

GameRegistry.registerBlock(basicFluidBlock, "basicFluidBlock");

 

Item basicBucket = new BasicBucket(basicFluidBlock).setContainerItem(Items.bucket)

.setUnlocalizedName("basicBucket");

 

GameRegistry.registerItem(basicBucket, "basicBucket");

FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("basicFluid",

FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(basicBucket),

new ItemStack(Items.bucket));

 

BucketHandler.INSTANCE.buckets.put(basicFluidBlock, basicBucket);

MinecraftForge.EVENT_BUS.register(BucketHandler.INSTANCE);

...

 

 

 

 

Here's the BucketHandler Class

 

 

 

 

package com.dvd.basic.fluids;

 

import java.util.HashMap;

import java.util.Map;

 

import cpw.mods.fml.common.eventhandler.Event.Result;

import net.minecraft.block.Block;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.world.World;

import net.minecraftforge.event.entity.player.FillBucketEvent;

 

public class BucketHandler {

 

public static BucketHandler INSTANCE = new BucketHandler();

    public Map<Block, Item> buckets = new HashMap<Block, Item>();

 

    private BucketHandler() {

    }

 

    //@ForgeSubscribe

    public void onBucketFill(FillBucketEvent event) {

 

            ItemStack result = fillCustomBucket(event.world, event.target);

 

            if (result == null)

                    return;

 

            event.result = result;

            event.setResult(Result.ALLOW);

    }

 

    private ItemStack fillCustomBucket(World world, MovingObjectPosition pos) {

 

            Block block = world.getBlock(pos.blockX, pos.blockY, pos.blockZ);

 

            Item bucket = buckets.get(block);

            if (bucket != null && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0) {

                    world.setBlockToAir(pos.blockX, pos.blockY, pos.blockZ);

                    return new ItemStack(bucket);

            } else

                    return null;

    }

 

}

 

 

 

 

I had to comment @ForgeSubscribe in the BucketHandler class because I got this error ("ForgeSubscribe cannot be resolved to a

type")

 

"I an atom in the universe, a universe of atoms"-- Richard P. Feynman

Link to comment
Share on other sites

I still can't get my texture to show up. I changed it to "registerBlockIcons" which makes the error in the console output go away but my texture still doesn't show up.

What do I have to do, other than follow this tutorial to make it work? I'm not even trying to make the bucket work. I've just been trying to get my custom liquid to have a texture for like a week.

Link to comment
Share on other sites

I still can't get my texture to show up. I changed it to "registerBlockIcons" which makes the error in the console output go away but my texture still doesn't show up.

What do I have to do, other than follow this tutorial to make it work? I'm not even trying to make the bucket work. I've just been trying to get my custom liquid to have a texture for like a week.

 

https://github.com/KeeperofMee/DrugMod

 

I got a fully functional fluid there with a custom potion effect, working texture(animated/still and flowing), particles in the water, working bucket etc...

It's not extremly organized as my other repositories, but it works.

And please for gods sake look and learn don't copy & paste.

 

Best regards

KeeperofMee(I love signing posts).

If I helped please press the Thank You button.

Link to comment
Share on other sites

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.

×
×
  • Create New...

Important Information

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