Jump to content

[Solved][1.7.2]Can someone explain adding new liquids to me?


Taji34

Recommended Posts

I looked at the tutorial on how to create a fluid for 1.7.2 (http://www.minecraftforge.net/wiki/Create_a_Fluid) but it seems to not be working. Either I am doing something wrong, or it has changed in forge because its saying that some of the classes don't exist or a methods are being undefined for an object type. Could someone explain the tutorial a bit more in depth to help me figure out either what has changed or where I am going wrong? if you need more info just ask and I'll post some screen caps of my eclipse workspace to show what is happening.

Link to comment
Share on other sites

Please post your exact symptoms. It is necessary for solving a problem.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

Link to comment
Share on other sites

Okay, I think you're right.  I quickly followed the tutorial and it seems that it isn't using the latest naming or icon methods for the block example.  For instance it uses the setUnlocalizedName() method, getIcon() methods, etc.

 

You should look at the latest ways to do the above (set name and set textures) for blocks to fix this.  I don't have time at the moment but will look into to it later this week.  But for example, the setUnlocalizedName() should be changed to setBlockName(), the registerIcons() should be changed to registerBlockIcons(), various places where it calls Icon it should be IIcon, etc.  Just follow through the various warnings in Eclipse and then check the super classes to see where the likely method intended is and override that.  The errors about the world.getBlockMaterial(x, y, z).isLiquid() should be changed I think to world.getBlock(x,  y,  z).getMaterial().isLiquid().

 

But yeah there do seem to be numerous mistakes or out of date info in that tutorial...

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Here is an example fluid I've added.. I followed the tutorial awhile ago.

 

Note: The naming convention is case sensative

 

also your textures need to be in the following

\texture\blocks\yourfluidflow.png

\texture\blocks\yourfluidflow.png.mcmeta

\texture\blocks\yourfluidstill.png

\texture\blocks\yourfluidstill.png.mcmeta

 

This is for BlockYourFluid.java

 

+ import net.minecraft.block.material.Material;

+ import net.minecraft.client.renderer.texture.IIconRegister;

+ import net.minecraft.creativetab.CreativeTabs;

+ import net.minecraft.util.IIcon;

+ import net.minecraft.world.IBlockAccess;

+ import net.minecraft.world.World;

+ import net.minecraftforge.fluids.BlockFluidClassic;

+ import net.minecraftforge.fluids.Fluid;

+ import cpw.mods.fml.relauncher.Side;

+ import cpw.mods.fml.relauncher.SideOnly;

+

+ public class BlockYourFluidFluid extends BlockFluidClassic

+ {

+ @SideOnly(Side.CLIENT)

+     protected IIcon stillIcon;

+     @SideOnly(Side.CLIENT)

+     protected IIcon flowingIcon;

+    

+     public BlockEcopoiesisFluid(Fluid fluid, Material material) {

+             super(fluid, material);

+             fluid.setUnlocalizedName("yourFluid");

+             setCreativeTab(CreativeTabs.tabMisc);

+     }

+    

+     @Override

+     public IIcon getIcon(int side, int meta) {

+             return (side == 0 || side == 1)? stillIcon : flowingIcon;

+     }

+    

+     @SideOnly(Side.CLIENT)

+     @Override

+     public void registerBlockIcons(IIconRegister register) {

+             stillIcon = register.registerIcon(YourMod.MODID + ":yourfluidstill");

+             flowingIcon = register.registerIcon(YourMod.MODID + ":yourfluidflow");

+     }

+   /*

+     @Override

+     public boolean canDisplace(IBlockAccess world, int x, int y, int z) {

+             if (world.getBlock(x,  y,  z).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).isLiquid()) return false;

+             return super.displaceIfPossible(world, x, y, z);

+     }*/

+

+ }

 

 

In your Block Class:

  declare them like so:

public static Fluid fluidYourFluid;

public static BlockYourFluidFluid fluidYourFluidBlock;

 

 

In Your Block Register Method

 

This is how you register it:

 

fluidYourFluidBlock = new BlockYourFluidFluid(fluidYourFluid, Material.water);

GameRegistry.registerBlock(fluidYourFluidBlock, "fluidYourFluid");

 

 

Sorry for the fragmentation - I'm working from my change logs to get this in place as I've redone how I handle my fluids but this should get you on the right path.

 

 

Link to comment
Share on other sites

 

Here is an example fluid I've added.. I followed the tutorial awhile ago.

 

Note: The naming convention is case sensative

 

also your textures need to be in the following

\texture\blocks\yourfluidflow.png

\texture\blocks\yourfluidflow.png.mcmeta

\texture\blocks\yourfluidstill.png

\texture\blocks\yourfluidstill.png.mcmeta

 

This is for BlockYourFluid.java

 

+ import net.minecraft.block.material.Material;

+ import net.minecraft.client.renderer.texture.IIconRegister;

+ import net.minecraft.creativetab.CreativeTabs;

+ import net.minecraft.util.IIcon;

+ import net.minecraft.world.IBlockAccess;

+ import net.minecraft.world.World;

+ import net.minecraftforge.fluids.BlockFluidClassic;

+ import net.minecraftforge.fluids.Fluid;

+ import cpw.mods.fml.relauncher.Side;

+ import cpw.mods.fml.relauncher.SideOnly;

+

+ public class BlockYourFluidFluid extends BlockFluidClassic

+ {

+ @SideOnly(Side.CLIENT)

+     protected IIcon stillIcon;

+     @SideOnly(Side.CLIENT)

+     protected IIcon flowingIcon;

+    

+     public BlockEcopoiesisFluid(Fluid fluid, Material material) {

+             super(fluid, material);

+             fluid.setUnlocalizedName("yourFluid");

+             setCreativeTab(CreativeTabs.tabMisc);

+     }

+    

+     @Override

+     public IIcon getIcon(int side, int meta) {

+             return (side == 0 || side == 1)? stillIcon : flowingIcon;

+     }

+    

+     @SideOnly(Side.CLIENT)

+     @Override

+     public void registerBlockIcons(IIconRegister register) {

+             stillIcon = register.registerIcon(YourMod.MODID + ":yourfluidstill");

+             flowingIcon = register.registerIcon(YourMod.MODID + ":yourfluidflow");

+     }

+   /*

+     @Override

+     public boolean canDisplace(IBlockAccess world, int x, int y, int z) {

+             if (world.getBlock(x,  y,  z).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).isLiquid()) return false;

+             return super.displaceIfPossible(world, x, y, z);

+     }*/

+

+ }

 

 

In your Block Class:

  declare them like so:

public static Fluid fluidYourFluid;

public static BlockYourFluidFluid fluidYourFluidBlock;

 

 

In Your Block Register Method

 

This is how you register it:

 

fluidYourFluidBlock = new BlockYourFluidFluid(fluidYourFluid, Material.water);

GameRegistry.registerBlock(fluidYourFluidBlock, "fluidYourFluid");

 

 

Sorry for the fragmentation - I'm working from my change logs to get this in place as I've redone how I handle my fluids but this should get you on the right path.

 

 

Thanks! It seems to be just the naming conventions (IIcon vs Icon) that have changed, but haven't been updated in the tutorial, once I get a fluid implemented, I will mark this thread as solved!

 

Edit: Ok, so isLiquid() is saying it is undefined for the type block on the line world.getBlock(x,  y,  z).isLiquid(), is it supposed to be something other than a block? Fixed it, turns out world.getBlockMaterial(x,  y,  z).isLiquid() changes to world.getBlock(x, y, y).getMaterial().isLiquid().

 

Edit 2: Ok, so I guess I must not be registering something right because it's just registering a null liquid. this is what i have for my liquidEnergy.java:

 

package com.taji34.troncraft;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class LiquidEnergy extends BlockFluidClassic {

@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;
    
public LiquidEnergy(Fluid fluid, Material material) {
	super(fluid, material);
	fluid.setUnlocalizedName("liquidEnergy");
	fluid.setLuminosity(5);
	setCreativeTab(CreativeTabs.tabMisc);
}

@Override
public IIcon getIcon(int side, int meta) {
	return (side == 0 || side == 1)? stillIcon : flowingIcon;
}

@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
	stillIcon = register.registerIcon("troncraft:liquidEnergyStill");
	flowingIcon = register.registerIcon("troncraft:liquidEnergyFlowing");
}

@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
	if (world.getBlock(x, y, y).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);
}
}

 

 

And this is what i have in my Troncraft.java:

 

package com.taji34.troncraft;

import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = Troncraft.MODID, version = Troncraft.VERSION)
public class Troncraft {
public static final String MODID = "troncraft";
    public static final String VERSION = "1.0a";
    
    @EventHandler
    public void init(FMLPreInitializationEvent event){
    	Fluid liquidEnergy = new Fluid("liquidenergy");
    	FluidRegistry.registerFluid(liquidEnergy);
    	LiquidEnergy liquidEnergyBlock = new LiquidEnergy(liquidEnergy, Material.water);
    	GameRegistry.registerBlock(liquidEnergyBlock, "YourFluid");
    	liquidEnergy.setUnlocalizedName(liquidEnergyBlock.getUnlocalizedName());
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {
    	
    }
}

 

 

What am I doing wrong? Do I need another class somewhere?

Link to comment
Share on other sites

What do you mean it is registering a null?  You mean you later try to use the block and it is null?  Could it be because in your code you register the name as "YourFluid" and then later try to call it by using liquid energy?  Basically I'm saying that you registered the block as "YourFluid" which probably isn't what you want to call it, maybe that is causing your trouble.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

What do you mean it is registering a null?  You mean you later try to use the block and it is null?  Could it be because in your code you register the name as "YourFluid" and then later try to call it by using liquid energy?  Basically I'm saying that you registered the block as "YourFluid" which probably isn't what you want to call it, maybe that is causing your trouble.

 

EDIT: Ok, got everything working! For those who stumble upon this thread, this is my code:

Troncraft.java:

 

package com.taji34.troncraft;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = Troncraft.MODID, version = Troncraft.VERSION)
public class Troncraft {

public static final String MODID = "troncraft";
    public static final String VERSION = "1.0a";
    public static Block liquidEnergyBlock;
    public static Fluid liquidEnergy;
    
    @EventHandler
    public void init(FMLPreInitializationEvent event){
    	liquidEnergy = new Fluid("liquidEnergy").setUnlocalizedName("liquidEnergy").setLuminosity(10);
	FluidRegistry.registerFluid(liquidEnergy);
    	liquidEnergyBlock = new LiquidEnergy(liquidEnergy, Material.water).setBlockName("liquidEnergy");
    	GameRegistry.registerBlock(liquidEnergyBlock, Troncraft.MODID + "_" + liquidEnergyBlock.getUnlocalizedName().substring(5));
    	liquidEnergy.setUnlocalizedName(liquidEnergyBlock.getUnlocalizedName());
    }
    
    @EventHandler
    public void init(FMLInitializationEvent event)
    {

    }
}

 

 

LiquidEnergy.java:

 

package com.taji34.troncraft;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;

public class LiquidEnergy extends BlockFluidClassic {

@SideOnly(Side.CLIENT)
protected IIcon stillIcon;
@SideOnly(Side.CLIENT)
protected IIcon flowingIcon;
    
public LiquidEnergy(Fluid fluid, Material material) {
	super(fluid, material);
	setCreativeTab(CreativeTabs.tabMisc);
}

@Override
public IIcon getIcon(int side, int meta) {
	return (side == 0 || side == 1)? stillIcon : flowingIcon;
}

@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister register) {
	stillIcon = register.registerIcon("troncraft:liquidEnergystill");
	flowingIcon = register.registerIcon("troncraft:liquidEnergyflow");
}

@Override
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
	if (world.getBlock(x, y, y).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);
}
}

 

The use of an en_US.lang file is needed for naming.

 

Original post before edits:

 

I saw that right after I posted the reply and nothing changed when I changed the name. This is what I mean about registering as null:

eSuflIF.png

(ignore the missing texture, that's just because I probably don't have the texture folder in the right place)

 

The problem is its name isn't working and none of the properties of the fluid are working (when I place it, no light is given off even though I set it's luminosity to 5). I think it has to be something with when I'm registering my liquid.

 

This is my preinitialization method:

    public void init(FMLPreInitializationEvent event){
    	Fluid liquidEnergy = new Fluid("liquidEnergy");
    	FluidRegistry.registerFluid(liquidEnergy);
    	LiquidEnergy liquidEnergyBlock = new LiquidEnergy(liquidEnergy, Material.water);
    	GameRegistry.registerBlock(liquidEnergyBlock, "liquidEnergy");
    	liquidEnergy.setUnlocalizedName(liquidEnergyBlock.getUnlocalizedName());
    }

 

Everything is correct/should be there?

 

Link to comment
Share on other sites

The reason why it says tile.null.name is because you only set the unlocalized name of the fluid, and not the actual block.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

The reason why it says tile.null.name is because you only set the unlocalized name of the fluid, and not the actual block.

 

Yeah, I realized that like an hour ago and just finished fixing it all up! I was actually editing my previous post when you replied.

Link to comment
Share on other sites

Yeah, for other people who may end up on this thread it would be good to post your final code.  But for a block you also have use the setBlockName() and also for it to fully display in CreativeTab properly you need your en_US.lang file to map the tile.liquidEnergy.name to "Liquid Energy" or similar.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.