Jump to content

Buckets In Slots Problem [UNSOLVED] [1.7.10]


Recommended Posts

Sorry to bother you again.


I have come across another problem, I am trying to make a method that allows me to fill an empty bucket from a tank in an inventory, and visa versa, fill an empty tank or a tank that has the same liquid as the bucket, from a bucket in a slot and return an empty bucket.


These are the methods so far; the fill tank from bucket kind of works, and the fill bucket from tank doesn't work.



Fill tank from bucket.

        public void fillTankFromContainer(FluidTank tank, int slot) {
	ItemStack container = this.getStackInSlot(slot);

	if (container != null) {
		if (FluidContainerRegistry.isFilledContainer(container)) {

			FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(container);
			if (fluid != null) {

				tank.fill(fluid, true);


And I am calling this method like:

this.fillTankFromContainer(tankOutput1, 0);

in the updateEntity() method to fill tankOutput1 from a bucket in slot 0.


Now the problem with this one that I cant figure out is that when I put the bucket in the slot, the bucket fills the tank, but doesn't empty, so what I mean is that the bucket keeps filling the tank until it is full, and the bucket of liquid stays in the slot. It does put 1000mB in at a time though, so that is good.


My second method; fill bucket from tank:

        public void fillContainerFromTank(FluidTank tank, int slot) {

	ItemStack container = this.getStackInSlot(slot);
	FluidStack fluid = tank.getFluid();

	if (fluid != null && container != null) {
		if (FluidContainerRegistry.isEmptyContainer(container)) {

			FluidContainerRegistry.fillFluidContainer(fluid, container);
			tank.drain(FluidContainerRegistry.getContainerCapacity(container), true);

And I am calling this method like:

this.fillContainerFromTank(tankOutput1, 0);

in the updateEntity() method to fill the bucket in slot 0 from tankOutput1


Now this doesn't work what soever. I put an empty bucket in, and absolutely nothing happens. I have no idea why.




I don't know why this isn't working. Is there something obvious that I have missed? or is this the complete wrong way to do this, or is there even a right or wrong way to do this?


Thanks for your help in advance.

I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.

Link to comment
Share on other sites

First problem, you never update the slot you have the container in. Try putting the return of drainFluidContainer(container) /* the now empty container */ into the slot selected after the call.


This method ...

FluidContainerRegistry.fillFluidContainer(fluid, container);

... returns the ItemStack when successful, or null on failure. You ignore the results, hence it does not do what you expect.

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.

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.


  • Create New...

Important Information

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