Posted September 3, 201411 yr 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.
September 3, 201411 yr Author anyone? I ask complicated questions, and apparently like to write really long detailed posts. But I also help others when I can.
September 4, 201411 yr 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. -S- (if I helped, please click Thank and applaud) http://6upnqa.dm2301.livefilestore.com/y2mtf-vG7Tqq1TiiVpIm53KWj7294NDPoHfSHHb4PzZiMAUfRCfK0UY0MwOu7Q3zTBNVTKqWjr2-xgBfFRpQT5p-QivtvknPpoABMNUw9br9WuZcBFkjePhnAbW500gVm-P/sequiturian.png[/img]
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.