Jump to content

picking up custom liquid in bucket


knarf2011

Recommended Posts

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.)

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.)

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://drive.google.com/file/d/1fPISu1m5Ica8CKDWj3PWVYPNgn85w2dk/view?usp=drive_link
    • @TileEntity no, the problem must be somewhere else, yes, we know that it eats a lot of frames, but it must be caused by something else, probably a mod or something, because for the first 10 days I played this modpack without problems on 4gb of ram, no problem, 200 fps, suddenly now when I start minecraft, minecraft runs for the first 2 minutes to 200 fps and suddenly the frame starts to be stretched very much. I assigned 8, then 12, then 16, and 24 gb of ram is just one amount. I always assign it after a different time, usually within 5 minutes, the game crashes due to lack of frame. the problem must be somewhere else, not only in the frame but in some mode or something strange, but it worked for me before and it works normally for my friends.
    • If you are using AMD/ATI, get the latest drivers from their website - do not update via system
    • So I don't have any other mods and I try to install my first mod. At first I tried turning on Forge but it didn't work for me. I entered into these logs and this is what debug I found.   [05maj2024 19:29:16.383] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, kod00, --version, 1.20.1-forge-47.2.30, --gameDir, C:\Users\Tadeusz\AppData\Roaming\.minecraft, --assetsDir, C:\Users\Tadeusz\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 0b6cb7d0d9794ea3995565e2c9e6961f, --accessToken, ????????, --clientId, ZmVhZDQ5MDEtODA2ZC00OTZhLTg1NWEtNDAzYzhmZGVhYzAx, --xuid, 2535448611541717, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\Tadeusz\AppData\Roaming\.minecraft\quickPlay\java\1714930153126.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.2.30, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [05maj2024 19:29:16.393] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0. 9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 [05maj2024 19:29:16.557] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow [05maj2024 19:29:16.668] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6   -------------------------------------------------------------   [05maj2024 19:29:16.383] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher running: args [--username, kod00, --version, 1.20.1-forge-47.2.30, --gameDir, C:\Users\Tadeusz\AppData\Roaming\.minecraft, --assetsDir, C:\Users\Tadeusz\AppData\Roaming\.minecraft\assets, --assetIndex, 5, --uuid, 0b6cb7d0d9794ea3995565e2c9e6961f, --accessToken, ????????, --clientId, ZmVhZDQ5MDEtODA2ZC00OTZhLTg1NWEtNDAzYzhmZGVhYzAx, --xuid, 2535448611541717, --userType, msa, --versionType, release, --quickPlayPath, C:\Users\Tadeusz\AppData\Roaming\.minecraft\quickPlay\java\1714930153126.json, --launchTarget, forgeclient, --fml.forgeVersion, 47.2.30, --fml.mcVersion, 1.20.1, --fml.forgeGroup, net.minecraftforge, --fml.mcpVersion, 20230612.114412] [05maj2024 19:29:16.393] [main/INFO] [cpw.mods.modlauncher.Launcher/MODLAUNCHER]: ModLauncher 10.0.9+10.0.9+main.dcd20f30 starting: java version 17.0.8 by Microsoft; OS Windows 10 arch amd64 version 10.0 [05maj2024 19:29:16.428] [main/DEBUG] [cpw.mods.modlauncher.LaunchServiceHandler/MODLAUNCHER]: Found launch services [fmlclientdev,forgeclient,minecraft,forgegametestserverdev,fmlserveruserdev,fmlclient,fmldatauserdev,forgeserverdev,forgeserveruserdev,forgeclientdev,forgeclientuserdev,forgeserver,forgedatadev,fmlserver,fmlclientuserdev,fmlserverdev,forgedatauserdev,testharness,forgegametestserveruserdev] [05maj2024 19:29:16.448] [main/DEBUG] [cpw.mods.modlauncher.NameMappingServiceHandler/MODLAUNCHER]: Found naming services : [srgtomcp] [05maj2024 19:29:16.468] [main/DEBUG] [cpw.mods.modlauncher.LaunchPluginHandler/MODLAUNCHER]: Found launch plugins: [mixin,eventbus,slf4jfixer,object_holder_definalize,runtime_enum_extender,capability_token_subclass,accesstransformer,runtimedistcleaner] [05maj2024 19:29:16.485] [main/DEBUG] [cpw.mods.modlauncher.TransformationServicesHandler/MODLAUNCHER]: Discovering transformation services [05maj2024 19:29:16.495] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path GAMEDIR is C:\Users\Tadeusz\AppData\Roaming\.minecraft [05maj2024 19:29:16.495] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path MODSDIR is C:\Users\Tadeusz\AppData\Roaming\.minecraft\mods [05maj2024 19:29:16.495] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path CONFIGDIR is C:\Users\Tadeusz\AppData\Roaming\.minecraft\config [05maj2024 19:29:16.495] [main/DEBUG] [net.minecraftforge.fml.loading.FMLPaths/CORE]: Path FMLCONFIG is C:\Users\Tadeusz\AppData\Roaming\.minecraft\config\fml.toml [05maj2024 19:29:16.550] [main/DEBUG] [cpw.mods.modlauncher.TransformationServicesHandler/MODLAUNCHER]: Found additional transformation services from discovery services:  [05maj2024 19:29:16.557] [main/INFO] [net.minecraftforge.fml.loading.ImmediateWindowHandler/]: Loading ImmediateWindowProvider fmlearlywindow [05maj2024 19:29:16.668] [main/INFO] [EARLYDISPLAY/]: Trying GL version 4.6   Can you help me with this?
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.