Jump to content

Recommended Posts

Posted

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.

Posted

Hi

 

I suspect the problem is here

 

                blockSewageWater = BlockSewageWater(155, "BlockSewageWater"); //Line 264

 

this should probably be

 

                blockSewageWater = new BlockSewageWater(155, "BlockSewageWater"); //Line 264

 

-TGG

 

Posted

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.

Posted

The reason

blockSewageWater = new BlockSewageWater(155, "BlockSewageWater"); //Line 264

is returning an undefined error is because the constructor for BlockSewage water is only accepting an integer as a parameter, not a integer and a string as you have in that variable.

Posted

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.

Posted

You have trouble constructing objects and fixing a null exception. That isn't an issue with Forge.

 

registerBLock(blockSewageWater, "FluidSewageWater");

Does that method exist ?

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Hi everyone, I'm currently developing a Forge 1.21 mod for Minecraft and I want to display a custom HUD overlay for a minigame. My goal: When the game starts, all players should see an item/block icon (from the base game, not a custom texture) plus its name/text in the HUD – similar to how the bossbar overlay works. The HUD should appear centered above the hotbar (or at a similar prominent spot), and update dynamically (icon and name change as the target item changes). What I've tried: I looked at many online tutorials and several GitHub repos (e.g. SeasonHUD, MiniHUD), but most of them use NeoForge or Forge versions <1.20 that provide the IGuiOverlay API (e.g. implements IGuiOverlay, RegisterGuiOverlaysEvent). In Forge 1.21, it seems that neither IGuiOverlay nor RegisterGuiOverlaysEvent exist anymore – at least, I can't import them and they are missing from the docs and code completion. I tried using RenderLevelStageEvent as a workaround but it is probably not intended for custom HUDs. I am not using NeoForge, and switching the project to NeoForge is currently not an option for me. I tried to look at the original minecraft source code to see how elements like hearts, hotbar etc are drawn on the screen but I am too new to Minecraft modding to understand. What I'm looking for: What is the correct way to add a custom HUD element (icon + text) in Forge 1.21, given that the previous overlay API is missing? Is there a new recommended event, callback, or method in Forge 1.21 for custom HUD overlays, or is everyone just using a workaround? Is there a minimal open-source example repo for Forge 1.21 that demonstrates a working HUD overlay without relying on NeoForge or deprecated Forge APIs? My ideal solution: Centered HUD element with an in-game item/block icon (from the base game's assets, e.g. a diamond or any ItemStack / Item) and its name as text, with a transparent background rectangle. It should be visible to the players when the mini game is running. Easy to update the item (e.g. static variable or other method), so it can change dynamically during the game. Any help, code snippets, or up-to-date references would be really appreciated! If this is simply not possible right now in Forge 1.21, it would also help to know that for sure. Thank you very much in advance!
    • The simple answer is there is not an easy way. You would need to know how to program in Java, as well as at least some familiarity with how Forge works so you could port the differences. You would also need the sourcecode for the original mod, and permission from the author to modify it, if they did not use some sort of open source license. So it's not impossible, but it would take some effort, but doing so would open up a whole new world of possibilities for you!
    • Does it still crash if you remove holdmyitems? Looks like that mod doesn't work on a server as far as I can tell from the error.  
    • Crashes the server when trying to start. Error code -1. Log  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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