forum Forumsplay_arrow Minecraft fiber_manual_record Mods

1

[forge] Help! crash when crafting custom liquid

1 emerald4 replies274 views
created 03/29/2013 7:36 am by Jt9
last reply 03/29/2013 9:33 am
I get this when I tried to test this mod :/

Click to reveal
java.lang.NullPointerException
at net.minecraft.item.ItemStack.func_77954_c(ItemStack.java:138)
at net.minecraft.client.renderer.entity.RenderItem.func_77015_a(RenderItem.java:339)
at net.minecraft.client.renderer.entity.RenderItem.func_82406_b(RenderItem.java:443)
at net.minecraft.client.gui.inventory.GuiContainer.func_74192_a(ayl.java:323)
at net.minecraft.client.gui.inventory.GuiContainer.func_73863_a(ayl.java:100)
at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1021)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:867)
at net.minecraft.client.Minecraft.run(Minecraft.java:756)
at java.lang.Thread.run(Thread.java:680)


Main class
Click to reveal
package moreliquids;

import java.io.File;

import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.block.Block;
import net.minecraftforge.liquids.LiquidContainerData;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
import moreliquids.proxy.CommonProxy;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid = "MoreLiquids", name = "MoreLiquids", version = "1.0")
@NetworkMod(clientSideRequired = true, serverSideRequired = false)

public class MoreLiquids
{
@Instance("MoreLiquids")
public static MoreLiquids instance;
public static final String TEXTURE_PREFIX = "moreliquids:";
public static final Configuration config = new Configuration(new File(Loader.instance().getConfigDir(), "MoreLiquids.cfg"));

public static Block milkFlowing;
public static Block milkStill;

public static Item bucketGlow;

public static LiquidStack milk;

@SidedProxy(clientSide = "moreliquids.proxy.ClientProxy", serverSide = "moreliquids.proxy.CommonProxy")
public static CommonProxy proxy;

@PreInit
public void preInit(FMLPreInitializationEvent event)
{

milkFlowing = new BlockMilkFlowing(config.getBlock("moreliquids.MilkFlowing", 3041).getInt());
milkStill = new BlockMilkStill(config.getBlock("moreliquids.MilkStill", 3042).getInt());

config.save();

if (milkFlowing.blockID + 1 != milkStill.blockID)
{
throw new RuntimeException("Milk Still id must be Milk Flowing id + 1");
}

milk = LiquidDictionary.getOrCreateLiquid("Milk", new LiquidStack(milkStill, 1));
LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getLiquid("Milk", LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(Item.bucketMilk), new ItemStack(Item.bucketEmpty)));
}

@Init
public void load(FMLInitializationEvent event)
{
LanguageRegistry.addName(milkFlowing, "Milk(Flowing)");
LanguageRegistry.addName(milkStill, "Milk(Stationary)");

MoreLiquidsRecipes.recipes();
}
@PostInit
public void postInit(FMLPostInitializationEvent event)
{

}
}


Other stuff
Click to reveal
package moreliquids;

import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class MoreLiquidsRecipes
{
public static void recipes()
{
GameRegistry.addRecipe(new ItemStack(MoreLiquids.milkFlowing, 1), new Object[] { "m", 'm', Item.bucketMilk});
}

}


Click to reveal
package moreliquids;

import net.minecraft.block.BlockFluid;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.world.World;
import net.minecraftforge.liquids.ILiquid;
import net.minecraft.creativetab.CreativeTabs;

public class BlockMilkFlowing extends BlockFluid implements ILiquid
{

public BlockMilkFlowing(int id)
{
super(id, Material.water);
setHardness(100F);
setLightOpacity(3);
setUnlocalizedName("MilkFlowing");
setCreativeTab(CreativeTabs.tabMisc);
}

@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(MoreLiquids.TEXTURE_PREFIX + "MilkFlow");
}

@Override
public int stillLiquidId()
{
return MoreLiquids.milkStill.blockID;
}

@Override
public boolean isMetaSensitive()
{
return false;
}

@Override
public int stillLiquidMeta()
{
return 0;
}

@Override
public boolean isBlockReplaceable(World world, int i, int j, int k)
{
return true;
}

}


Click to reveal
package moreliquids;

import net.minecraft.block.BlockStationary;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.world.World;
import net.minecraftforge.liquids.ILiquid;
import net.minecraft.creativetab.CreativeTabs;

public class BlockMilkStill extends BlockStationary implements ILiquid
{

public BlockMilkStill(int id)
{
super(id, Material.water);
setHardness(100F);
setLightOpacity(3);
setUnlocalizedName("MilkStill");
setCreativeTab(CreativeTabs.tabMisc);
}

@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon(MoreLiquids.TEXTURE_PREFIX + "MilkStill");
}

@Override
public int stillLiquidId()
{
return this.blockID;
}

@Override
public boolean isMetaSensitive()
{
return false;
}

@Override
public int stillLiquidMeta()
{
return 0;
}

@Override
public boolean isBlockReplaceable(World world, int i, int j, int k)
{
return true;
}

}


It compiled fine, just crashed when I tried to craft the liquid.
Posted by avatar
Jt9
Level 67 : High Grandmaster Modder
251

4 replies

1
03/29/2013 9:33 am
Level 67 : High Grandmaster Modder
Jt9
avatar
Well, Minecraft already has the milk bucket, so I'm not sure. I will add another liquid with a bucket so that I can test it, I just made the recipe because I wanted to see the liquid. I'm still not sure about it not showing up in the creative tab, it won't even show up in Too Many Items. The config file works, but it just won't show up in game :/
1
03/29/2013 9:23 am
Level 65 : High Grandmaster Cyborg
Teotoo
avatar
Oh yes, of course - whoops!

It could just be that you cant craft a liquid.

Which would be logical. Have you tried crafting a bucket of the liquid?
1
03/29/2013 7:42 am
Level 65 : High Grandmaster Cyborg
Teotoo
avatar
Have you tried using milk as a LiquidStack in the recipe instead?
1
03/29/2013 8:07 am
Level 67 : High Grandmaster Modder
Jt9
avatar
It just gave me an error because the addRecipe method was made for ItemStack, not LiquidStack

Planet Minecraft

Browse

Site

© 2010 - 2019
planetminecraft.com

Welcome