Posted April 15, 201411 yr So I was playing around with fluids in guis and when I try to put a fluid into a tank using the method from the FluidContainerRegistry, it always returns null. Even if I put a water bucket or a lava bucket. If I try to put in a fluid without using that method, just defining one like: FluidStack fluid = new FluidStack(Mod.fluid, bucketSize); it works, but not when I'm using the method to get the the fluid out of the bucket. TileEntity Code: (The only important part is updateEntity(), all other code works fine and is tested, so I'm just posting that method) @Override public void updateEntity() { FluidStack fluid = tank.getFluid(); int bucketSize = FluidContainerRegistry.BUCKET_VOLUME; if (!worldObj.isRemote) { ItemStack stack = items[0]; if (stack != null) { FluidStack liquid = null; if (stack.getItem().getContainerItem() != null) { liquid = FluidContainerRegistry.getFluidForFilledItem(stack); } if (liquid != null) { if (fill(ForgeDirection.UNKNOWN, liquid, false) == liquid.amount) { fill(ForgeDirection.UNKNOWN, liquid, true); setInventorySlotContents(0, consumeItem(stack)); //consumes the item (for method look down below) } } } if (items[1] != null) { if (FluidContainerRegistry.isBucket(items[1])) { if (tank.getFluid() != null) { if (tank.getFluidAmount() >= bucketSize) { setInventorySlotContents(1, FluidContainerRegistry.fillFluidContainer(tank.getFluid(), items[1])); drain(ForgeDirection.UNKNOWN, tank.getFluid(), bucketSize, true); } } } } } } I've got two slots; one for filling and one for draining a bucket. The drain() and fill() methods are both working, there is nothing wrong there. consumeItem(ItemStack stack): public static ItemStack consumeItem(ItemStack stack) { if (stack.stackSize == 1) { if (stack.getItem().getContainerItem() != null) { return stack.getItem().getContainerItem(stack); } else { return null; } } else { stack.splitStack(1); return stack; } } Thanks for any help! My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
April 20, 201411 yr Author I've also noticed that the fillFluidContainer(FluidStack fluid, ItemStack container) also returns null, is this an error/problem on my side of coding or does the Forge code simply not work. Would be grateful for any answer. My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
April 21, 201411 yr Check your version of Forge. Before 10.12.0.1034 there were quite a lot bugs in the fluid api that resulted in problems like you are describing. The only other thing I can think of is that your itemstack is invalid (null or not a registered fluid container).
April 21, 201411 yr Author That fixed it, needed to update forge, 1+ for you My mod for futher awesomeness: http://www.minecraftforum.net/topic/1714396-the-decopack-collection-v010-wip-made-a-signature-new-snapshot-1-screenshots-are-up-small-snapshot-1-is-out-for-147/#entry21250399
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.