Fixed barrel bottle extraction not draining liquid
Fixed an issue where taking filling a water bottle from a barrel would fill the bottle but not drain the barrel. This is due to mismatched NBT values when extracting. This change moves the drain operation before the NBT operations and only modifies the item NBT if fluid NBT is present.
This commit is contained in:
parent
906cf0f658
commit
3d14eeaf89
|
|
@ -335,13 +335,15 @@ public class BarrelBlockEntity extends ETankBlockEntity {
|
|||
if (!player.getAbilities().instabuild) {
|
||||
playerItem.shrink(1);
|
||||
}
|
||||
tank.drain(fluid, IFluidHandler.FluidAction.EXECUTE);
|
||||
var bottle = PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER);
|
||||
var nbt = bottle.getOrCreateTag();
|
||||
nbt.merge(fluid.getOrCreateTag());
|
||||
if (fluid.hasTag()) {
|
||||
var nbt = bottle.getOrCreateTag();
|
||||
nbt.merge(fluid.getTag());
|
||||
}
|
||||
if (!player.addItem(bottle)) {
|
||||
player.drop(bottle, false);
|
||||
}
|
||||
tank.drain(fluid, IFluidHandler.FluidAction.EXECUTE);
|
||||
level.playSound(null, player.getX(), player.getY(), player.getZ(), SoundEvents.BOTTLE_EMPTY, SoundSource.NEUTRAL, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user