Jump to content

Recommended Posts

Posted

I am attempting to add flowing acid to the burning war mod( http:/www.planetminecraft.com/mod/burning-war-mod-forge-15-a/ ). This is a custom liquid which erodes blocks it touches. The erosion part is tested and working, as is the texture, but when  I try to pick up the liquid I get a bucket of water instead. How can I make the bucket pick up my liquid? (I already made my custom bucket, and it properly dumps out the liquid.)

Posted

just go trough the classes and u'll find what you need.

For example, thats in the ItemBucket class file:

 

(it's in onItemRightClick)
if (par2World.getBlockMaterial(i, j, k) == Material.water && par2World.getBlockMetadata(i, j, k) == 0)
                    {
                        par2World.setBlockToAir(i, j, k);

                        if (par3EntityPlayer.capabilities.isCreativeMode)
                        {
                            return par1ItemStack;
                        }

                        if (--par1ItemStack.stackSize <= 0)
                        {
                            return new ItemStack(Item.bucketWater);
                        }

                        if (!par3EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketWater)))
                        {
                            par3EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketWater.itemID, 1, 0));
                        }

                        return par1ItemStack;
                    }

 

i believe that's the part when player is rightclicking on wather holding a bucket.

Just customize it a lil bit.. replacing bucketwather with ur own liquid.

 

ps: still don't know if it's like this.... jsut guessin' ^^ im quiet new :P

 

 

Cheers,

-East

Posted

I have a mod that has two liquids, so I know exactly what you need. (I had the same water bucket problem). First, I hope you registered your liquid with forges liquid dictionary.

 

 

The acid bucket item should have .setContainerItem(Item.bucketEmpty)

 

Then add this to your @PreInit method

MinecraftForge.EVENT_BUS.register(new AcidBucketHandler());

You can name "AcidBucketHandler" whatever you want.

 

Then in your @Init method add this:

LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getLiquid("Acid", LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(
			Yourmod.bucketAcid), new ItemStack(Item.bucketEmpty)));

Replace "Yourmod" with whatever class defines your bucket. Replace "bucketEmpty" with a custom bucket if you want. "Acid" is whatever name you registered your liquid in. (this one)

LiquidDictionary.getOrCreateLiquid([u][b]"Acid"[/b][/u],blablabla

 

Then you need to make a new java file "AcidBucketHandler"

package yourpackage;

import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;

public class AcidBucketHandler
{
@ForgeSubscribe
public void onBucketFill(FillBucketEvent event)
{

	ItemStack result = fillCustomBucket(event.world, event.target);

	if (result == null)
		return;

	event.result = result;
	event.setResult(Result.ALLOW);
}

public ItemStack fillCustomBucket(World world, MovingObjectPosition pos)
{
	int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ);

	if ((blockID == YourMod.AcidStill.blockID || blockID == YourMod.acidMoving.blockID) && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0)
	{
		world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
		return new ItemStack(YourMod.bucketAcid);
	}
	else
		return null;
}

}

 

 

I figured this out when I looked at the buildcraft source code. The source codes of other mods really help

 

Posted

I have a mod that has two liquids, so I know exactly what you need. (I had the same water bucket problem). First, I hope you registered your liquid with forges liquid dictionary.

 

 

The acid bucket item should have .setContainerItem(Item.bucketEmpty)

 

Then add this to your @PreInit method

MinecraftForge.EVENT_BUS.register(new AcidBucketHandler());

You can name "AcidBucketHandler" whatever you want.

 

Then in your @Init method add this:

LiquidContainerRegistry.registerLiquid(new LiquidContainerData(LiquidDictionary.getLiquid("Acid", LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(
			Yourmod.bucketAcid), new ItemStack(Item.bucketEmpty)));

Replace "Yourmod" with whatever class defines your bucket. Replace "bucketEmpty" with a custom bucket if you want. "Acid" is whatever name you registered your liquid in. (this one)

LiquidDictionary.getOrCreateLiquid([u][b]"Acid"[/b][/u],blablabla

 

Then you need to make a new java file "AcidBucketHandler"

package yourpackage;

import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.event.Event.Result;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.player.FillBucketEvent;

public class AcidBucketHandler
{
@ForgeSubscribe
public void onBucketFill(FillBucketEvent event)
{

	ItemStack result = fillCustomBucket(event.world, event.target);

	if (result == null)
		return;

	event.result = result;
	event.setResult(Result.ALLOW);
}

public ItemStack fillCustomBucket(World world, MovingObjectPosition pos)
{
	int blockID = world.getBlockId(pos.blockX, pos.blockY, pos.blockZ);

	if ((blockID == YourMod.AcidStill.blockID || blockID == YourMod.acidMoving.blockID) && world.getBlockMetadata(pos.blockX, pos.blockY, pos.blockZ) == 0)
	{
		world.setBlock(pos.blockX, pos.blockY, pos.blockZ, 0);
		return new ItemStack(YourMod.bucketAcid);
	}
	else
		return null;
}

}

 

 

I figured this out when I looked at the buildcraft source code. The source codes of other mods really help

 

Thanks. I looked at buildcraft too. Someone really needs to make a tutorial on this, all the help people ever get is "look at buildcraft". (which is helpful, but not as simple as watching a tutorial.)

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.