Jump to content

Recommended Posts

Posted

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!

Posted
  On 3/7/2014 at 5:03 PM, Dispellz said:

 

This is for 1.6.4, but most of this stuff should be easy to covert to 1.7.2

 

1.7 was a COMPLETE REWRITE of 1.6.4. There were no IDs, the texture classes were different, etc. Could you provide me a 1.7.2 example? That is what I specifically asked for, a 1.7.2 version. Thanks

Posted

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);
    }
}

  • 2 months later...
Posted

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:

 

  Reveal hidden contents

 

Posted

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

 

Here's the crash-log

 

 

  Reveal hidden contents

 

 

Here's my Main Class

 

 

  Reveal hidden contents

 

 

 

  Reveal hidden contents

 

 

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

Posted

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

 

 

  Reveal hidden contents

 

 

Here's the BucketHandler Class

 

 

  Reveal hidden contents

 

 

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

Posted

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.

Posted
  On 6/9/2014 at 12:26 AM, Veraster said:

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.

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.

Announcements



×
×
  • Create New...

Important Information

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