Jump to content

[SOLVED] Custom Liquid Issues


Tyler_Watson

Recommended Posts

I'm trying to create a custom liquid and I can get the game running but I cant give myself the liquid and the tutorial I followed didn't explain anything very well. I get a crash file but I can't figure out whats wrong with it. Any help would be great.

Here's my code:

 

BlockSewageWater

package TylerWatson.Mod;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class BlockSewageWater extends BlockFluidClassic{

public BlockSewageWater(int id) {
	super(id, PenguinMod.fluidSewageWater, Material.water);

	this.setCreativeTab(PenguinMod.tabPenguin);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta){
	return Block.waterMoving.getIcon(side,  meta);
}

@Override
public int colorMultiplier(IBlockAccess iblockaccess, int x, int y, int z)
{
	return 0x8E2D00; // HEX color code as indicated by the 0x infront. This is a greenish color. <---No
	}
}

 

FluidSewageWater

package TylerWatson.Mod;

import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;

public class FluidSewageWater extends Fluid{

public FluidSewageWater(String fluidName) {
	super("SewageWater");

	setDensity(10); // How thick the fluid is, affects movement inside the liquid.
	setViscosity(1000); // How fast the fluid flows.
	FluidRegistry.registerFluid(this); // Registering inside it self, keeps things neat 
	}
}

 

Main Class

        //Liquids
        public static Fluid fluidSewageWater;
        public static Block blockSewageWater;
        public static final int idSewageWater = 155;

And inside my @EventHandler

            //Liquids TODO fix
                fluidSewageWater = new Fluid("FluidSewageWater").setBlockID(idSewageWater);
                fluidSewageWater = new FluidSewageWater(null);
                blockSewageWater = BlockSewageWater(155, "BlockSewageWater"); //Line 264
                GameRegistry.registerBlock(blockSewageWater, "BlockSewageWater");
                LanguageRegistry.addName(blockSewageWater, "Sewage Water");

 

Crash log

---- Minecraft Crash Report ----
// Everything's going to plan. No, really, that was supposed to happen.

Time: 11/23/13 5:36 PM
Description: There was a severe problem during mod loading that has caused the game to fail

cpw.mods.fml.common.LoaderException: java.lang.NullPointerException
at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:232)
at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:195)
at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:171)
at TylerWatson.Mod.PenguinMod.load(PenguinMod.java:265)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:540)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)
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:193)
at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:173)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.google.common.eventbus.EventHandler.handleEvent(EventHandler.java:74)
at com.google.common.eventbus.SynchronizedEventHandler.handleEvent(SynchronizedEventHandler.java:45)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:313)
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:104)
at cpw.mods.fml.common.Loader.initializeMods(Loader.java:697)
at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:222)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:506)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:796)
at net.minecraft.client.main.Main.main(Main.java:93)
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:57)
at net.minecraft.launchwrapper.Launch.main(Launch.java:18)
Caused by: java.lang.NullPointerException
at cpw.mods.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:214)
... 40 more


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

-- System Details --
Details:
Minecraft Version: 1.6.2
Operating System: Windows 8 (amd64) version 6.2
Java Version: 1.7.0_13, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 957589488 bytes (913 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
Suspicious classes: FML and Forge are installed
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v8.04 FML v6.2.19.789 Minecraft Forge 9.10.0.789 4 mods loaded, 4 mods active
mcp{8.04} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized
FML{6.2.19.789} [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized
Forge{9.10.0.789} [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized
penguinmod{Pre-Alpha v0.001} [Penguin & Coconut Mod] (bin) Unloaded->Constructed->Pre-initialized->Errored

 

Anyone that has a good tutorial or can fix my issue would be appreciated.

Link to comment
Share on other sites

I tried that but I get the error:

The constructor BlockSewageWater(int, string) is undefined

 

Also in my BlockSewageWater class i'm getting an error:

package TylerWatson.Mod;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class BlockSewageWater extends BlockFluidClassic{

public BlockSewageWater(int id) {
	super(id, PenguinMod.fluidSewageWater, Material.water);

	this.setCreativeTab(PenguinMod.tabPenguin);
}
@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta){
	return Block.waterMoving.getIcon(side,  meta);
}

@Override
public int colorMultiplier(IBlockAccess iblockaccess, int x, int y, int z)
{
	return 0x8E2D00; // HEX color code as indicated by the 0x infront. This is a greenish color. <---No
	}
}

 

The super gives me an error on PenguinMod.fluidSewageWater that says:

fluidSewageWater can't be resolved or is not a field.

 

I have no idea how to fix this because I'm not too familiar with Forge yet.

Link to comment
Share on other sites

I went back to the tutorial and followed the code exactly and I have no errors in my code but in the console it says ~~ERROR~~ NullPointerException: null

 

Code:

 

MainClass

        //Liquids TODO fix
        public static Block blockSewageWater;
        public static Fluid fluidSewageWater;
        public static Material materialSewageWater;
        public static final int idSewageWater = 155;

And

                fluidSewageWater = new Fluid("FluidSewageWater").setBlockID(idSewageWater);
                FluidRegistry.registerFluid(fluidSewageWater);
                materialSewageWater = new MaterialLiquid(MapColor.dirtColor);
                blockSewageWater = new BlockSewageWater(idSewageWater, fluidSewageWater, materialSewageWater).setUnlocalizedName("SewageWater");
                registerBLock(blockSewageWater, "FluidSewageWater");

 

BlockSewageWater

package TylerWatson.Mod;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class BlockSewageWater extends BlockFluidClassic{

public BlockSewageWater(int id, Fluid fluid, Material material) {
	super(id, fluid, material);
	this.setCreativeTab(PenguinMod.tabPenguin); 
}



@Override
@SideOnly(Side.CLIENT)
public Icon getIcon(int side, int meta){
	return Block.waterMoving.getIcon(side,  meta);
}

@Override
public int colorMultiplier(IBlockAccess iblockaccess, int x, int y, int z)
{
	return 0x8E2D00; // HEX color code as indicated by the 0x infront. This is a greenish color. <---No
	}
}

I'm sorry if it seems like I don't know what I'm doing. I have an intermediate knowledge of java, but I'm at a loss when it comes to fixing issues in forge.

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.

Announcements



×
×
  • Create New...

Important Information

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