Posted November 22, 201410 yr Hello, I'm trying to create a custom coffee liquid. I semi-followed(I know the "semi-" part is where I went wrong, I just can't find what I didn't do/changed that would affect it in this way) the tutorial on the wiki here: http://www.minecraftforge.net/wiki/Create_a_Fluid however, when I try to run the game, I get the following error: 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.darichey.ACOJ.block.BlockLiquidCoffee.<init>(BlockLiquidCoffee.java:27) at com.darichey.ACOJ.init.ModBlocks.<clinit>(ModBlocks.java:22) ... 47 more The init() method from the following class is called from my preInit() method in my main class: public class ModBlocks { public static final Fluid LiquidCoffee = new LiquidCoffee(); public static final BlockFluidClassic BlockLiquidCoffee = new BlockLiquidCoffee(LiquidCoffee, Material.water); public static void init() { GameRegistry.registerBlock(BlockLiquidCoffee, Names.LIQUID_COFFEE_BLOCK); FluidRegistry.registerFluid(LiquidCoffee); } } The LiquidCoffee class: public class LiquidCoffee extends Fluid { public LiquidCoffee() { super(Names.LIQUID_COFFEE); this.setUnlocalizedName(Names.LIQUID_COFFEE); this.setViscosity(2000); } } The BlockLiquidCoffee class: public class BlockLiquidCoffee extends BlockFluidClassic { @SideOnly(Side.CLIENT) protected IIcon stillIcon; @SideOnly(Side.CLIENT) protected IIcon flowingIcon; public BlockLiquidCoffee(Fluid fluid, Material material) { super(fluid, material); this.setCreativeTab(CreativeTabACOJ.ACOJ_TAB); this.setBlockName(Names.LIQUID_COFFEE_BLOCK); } @Override public IIcon getIcon(int side, int meta) { return (side == 0 || side == 1)? stillIcon : flowingIcon; } @SideOnly(Side.CLIENT) @Override public void registerBlockIcons(IIconRegister iconRegister) { stillIcon = iconRegister.registerIcon(Reference.MOD_ID + ":LiquidCoffeeStill"); flowingIcon = iconRegister.registerIcon(Reference.MOD_ID + ":LiquidCoffeeFlowing"); } @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've forgotten to include any relevant code, please tell me. Thanks!
November 22, 201410 yr Try swapping these two lines: GameRegistry.registerBlock(BlockLiquidCoffee, Names.LIQUID_COFFEE_BLOCK); FluidRegistry.registerFluid(LiquidCoffee); Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
November 22, 201410 yr Author Thank you for your reply. I've done so with the ModBlocks class now looking like this: public class ModBlocks { public static final Fluid LiquidCoffee = new LiquidCoffee(); public static final BlockFluidClassic BlockLiquidCoffee = new BlockLiquidCoffee(LiquidCoffee, Material.water); public static void init() { FluidRegistry.registerFluid(LiquidCoffee); GameRegistry.registerBlock(BlockLiquidCoffee, Names.LIQUID_COFFEE_BLOCK); } } However, the problem still persists. The error is identical.
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.