Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Buckets In Slots Problem [UNSOLVED] [1.7.10]

Featured Replies

Posted

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);
				FluidContainerRegistry.drainFluidContainer(container);
			}
		}
	}
}

 

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.

  • Author

anyone?

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

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.