Jump to content

Recommended Posts

Posted

Hi, everyone. I'm a beginner modder and I'm trying to figure out how to create liquids in Minecraft. The problem is, I'm don't know how to do it correctly. I tried using this tutorial to figure out how: http://www.minecraftforge.net/wiki/Creating_a_Liquid however, after following it's instructions, my "liquid" appeared as a solid block instead. So, yeah, I'm kind of noobish at modding, however, I'd really appreciate it if someone could tell me how to correctly create liquids for Forge 1.5.2. Thanks.

Posted

Hey, does the block act like a liquid at all? like does it flow? or can you literally stand on top of it.

 

I wrote the tutorial purely because there was none, and it took me a few days to work out liquid code. I never touched on animation or anything like that, because I still don't know how that works. Also note the tutorial is for 1.4.7

 

If it's actually acting like a solid block post up the code, and I'll see if I see anything obvious.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

You need to create a flowing block and a still block, optimally the flowing block is one id below the still block, but I think you can change the code somewhere if you cant do that.  then for your flowing block class use

 

extends BlockFluid implements ILiquid

 

then for the stationary block class use

 

extends BlockStationary implements ILiquid

Posted

Yeah, it's a solid block. I can walk on it, it's breakable, and it doesn't flow. Also, I don't know what's the difference between iLiquid and the LiquidDictionary. I'm a mega-newbie at this.

Posted

Okay, so this is what I got so far with your advice.

 

This is the code for the stationary block:

package arturomod.base;

import net.minecraft.block.BlockStationary;
import net.minecraft.block.material.Material;
import net.minecraftforge.liquids.ILiquid;

public class ArturoLiquidStill extends BlockStationary implements ILiquid {

protected ArturoLiquidStill(int par1, Material par2Material) {
	super(501, Material.water);
	// TODO Auto-generated constructor stub
}

@Override
public int stillLiquidId() {
	// TODO Auto-generated method stub
	return 501;
}

@Override
public boolean isMetaSensitive() {
	// TODO Auto-generated method stub
	return false;
}

@Override
public int stillLiquidMeta() {
	// TODO Auto-generated method stub
	return 0;
}

}

 

And here's the code for the flowing block:

package arturomod.base;

import net.minecraft.block.BlockFlowing;
import net.minecraft.block.material.Material;
import net.minecraftforge.liquids.ILiquid;

public class ArturoLiquidFlowing extends BlockFlowing implements ILiquid {

protected ArturoLiquidFlowing(int par1, Material par2Material) {
	super(502, Material.water);
	// TODO Auto-generated constructor stub
}

@Override
public int stillLiquidId() {
	// TODO Auto-generated method stub
	return 501;
}

@Override
public boolean isMetaSensitive() {
	// TODO Auto-generated method stub
	return false;
}

@Override
public int stillLiquidMeta() {
	// TODO Auto-generated method stub
	return 0;
}

}

 

I have to admit that I'm a little confused, because the ILiquid constructors are exactly the same for both files. Is that normal or am I doing good? Also, I appear to have a little trouble trying to register the block. The code I'm using for that is:

public final static BlockStationary arturoLiquidStill = new ArturoLiquidStill;

 

The problem here is that Eclipse is saying that there's a "syntax error" under the word "new".

Posted

Okay. I registered it like so, and now that's fixed. My liquid is now registered in the game, but now unfortunately, we've got ANOTHER problem: the liquid is not flowing. I place the block on the ground, and it doesn't flow. Also, when I pick it up, it first turns into a solid block, so when I break that solid block, that's how the liquid disappears. Man, this is a lot harder than I thought.

Posted

make flowing liquid id 501, and the still block id 502 or  modify/override this code in the still block.  its prob just easier to change the block ID to avoid confusion.

 

/**
* Changes the block ID to that of an updating fluid.
*/
private void setNotStationary(World par1World, int par2, int par3, int par4)
{
    int l = par1World.getBlockMetadata(par2, par3, par4);
    par1World.setBlock(par2, par3, par4, this.blockID - 1, l, 2);
    par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID - 1, this.tickRate(par1World));
}

 

as you can see by default they have the still block subtracting 1 from the ID for flowing.

Posted

Well, that helped a bit more. I switched the item IDs of the two files, but now another strange error has arisen: the liquid only flows when I place a block next to it. Also, it appears that my generic block which I named "Arturo Block" has now taken the name of "Arturo Liquid".

 

I checked the base mod code and the Block's code, and I don't see at ALL what's causing this error with the Language Registry. Why is this happening?

 

package arturomod.base;

import net.minecraft.block.Block;
import net.minecraft.block.BlockStationary;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.liquids.IBlockLiquid;
import net.minecraftforge.liquids.ILiquid;
import net.minecraftforge.liquids.LiquidStack;
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.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="Arturo166_Mod", name="Arturo's Mod", version="1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Arturo {

public final static Block arturoBlock = new BlockArturoBlock(500, 0);

public final static Block arturoLiquidStill = new ArturoLiquidStill(502, 0);

public final static Block arturoLiquidFlowing = new ArturoLiquidFlowing(501, 0);

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

@PreInit
public void preInit(FMLPreInitializationEvent event) {

}

@Init
public void load(FMLInitializationEvent event) {

	GameRegistry.registerBlock(arturoBlock, "arturoBlock");
	LanguageRegistry.addName(arturoBlock, "Arturo Block");

	GameRegistry.registerBlock(arturoLiquidStill, "arturoLiquidStill");
	LanguageRegistry.addName(arturoLiquidStill, "Arturo Liquid Still");

	GameRegistry.registerBlock(arturoLiquidFlowing, "arturoLiquidFlowing");
	LanguageRegistry.addName(arturoLiquidFlowing, "Arturo Liquid");

}

@PostInit
public void postInit(FMLPostInitializationEvent event) {

}

}

Posted

Add this to your still block to get the liquid to flow when placed in world.

 

public void onBlockAdded(World par1World, int par2, int par3, int par4) {
 if (par1World.getBlockId(par2, par3, par4) == this.blockID)
    {
        this.setNotStationary(par1World, par2, par3, par4);
    }
}

Posted

Well, I copy-pasted that code into the still-liquid file, and it caused the game to crash whenever I hit the liquid, and it didn't flow. Are there a few things in the code I have to change? Also, in case it has something to do with where in the code I put it, I placed it above the superclass constructor.

Posted

copy buildcraft's oil code from their github.

 

The buildcraft oil code is massively complicated if you're new to liquids. Trust me, I tried to learn from it and got nowhere. Plus, isn't that against their license?

 

Arturo, not sure how useful this will be, but here's the github from the mod I was making when I wrote the (admittedly bad) liquid tutorial. Feel free to learn from the liquid code; I got buckets working with it too which isn't on the tutorial.

https://github.com/Flenix/FlenixRoads/tree/master/co/uk/silvania/roads

 

Let me know if that helps or if you have questions from anything. Feel free to fork it and delete all but the liquid code so you can work out how it works etc without the clutter of the rest of the mod.

width=463 height=200

http://s13.postimg.org/z9mlly2av/siglogo.png[/img]

My mods (Links coming soon)

Cities | Roads | Remula | SilvaniaMod | MoreStats

Posted

Thanks, man! The code in your mod gave me a fully functioning liquid! But uhh, now I've got another problem that I don't see any errors in: to test your mod, I created a new liquid altogether called "Arturo Liquid 2". But the thing is, now everything I implemented into the mod is using that name, and I don't know how to solve it. I checked the code I used for the LanguageRegistry and I used different strings and different names for each item. So what's causing this?

Posted

Not sure what you mean there, but I'll show you the code to see if you can point it out to me.

 

 

package arturomod.base;

import net.minecraft.block.Block;
import net.minecraft.block.BlockStationary;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraftforge.liquids.IBlockLiquid;
import net.minecraftforge.liquids.ILiquid;
import net.minecraftforge.liquids.LiquidStack;
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.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;

@Mod(modid="Arturo166_Mod", name="Arturo's Mod", version="1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false)
public class Arturo {

public static final Block arturoBlock = new BlockArturoBlock(500, 0);

public static final Block arturoLiquidStill = new ArturoLiquidStill(502, 0);

public static final Block arturoLiquidFlowing = new ArturoLiquidFlowing(501, 0);

public static final Block arturoLiquidStill2 = new ArturoLiquidStill2(504, 0);

public static final Block arturoLiquidFlowing2 = new ArturoLiquidFlowing2(503, 0);

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

@PreInit
public void preInit(FMLPreInitializationEvent event) {

}

@Init
public void load(FMLInitializationEvent event) {

	GameRegistry.registerBlock(arturoBlock, "arturoBlock");
	LanguageRegistry.addName(arturoBlock, "Arturo Block");

	GameRegistry.registerBlock(arturoLiquidStill, "arturoLiquidStill");
	LanguageRegistry.addName(arturoLiquidStill, "Arturo Liquid-Still");

	GameRegistry.registerBlock(arturoLiquidFlowing, "arturoLiquidFlowing");
	LanguageRegistry.addName(arturoLiquidFlowing, "Arturo Liquid");

	GameRegistry.registerBlock(arturoLiquidStill2, "arturoLiquidStill2");
	LanguageRegistry.addName(arturoLiquidStill2, "Arturo Liquid 2-Still");

	GameRegistry.registerBlock(arturoLiquidFlowing2, "arturoLiquidFlowing2");
	LanguageRegistry.addName(arturoLiquidFlowing2, "Arturo Liquid 2");

}

@PostInit
public void postInit(FMLPostInitializationEvent event) {

}

}

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.