Fix #1859
This commit is contained in:
parent
6151757914
commit
371c1fe21b
1 changed files with 8 additions and 2 deletions
|
@ -133,7 +133,7 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
|
|||
FluidState fluidState = usageContext.getWorld().getFluidState(pos);
|
||||
if(fluidState.getFluid() != Fluids.EMPTY && fluidState.isStill()){
|
||||
stack.decrement(1);
|
||||
usageContext.getPlayer().inventory.insertStack(getCellWithFluid(fluidState.getFluid(), 1));
|
||||
insertOrDropStack(usageContext.getPlayer(), getCellWithFluid(fluidState.getFluid(), 1));
|
||||
usageContext.getWorld().setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
playEmptyingSound(usageContext.getPlayer(), usageContext.getWorld(), pos, fluidState.getFluid());
|
||||
}
|
||||
|
@ -141,13 +141,19 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
|
|||
if(blockState.canReplace(new ItemPlacementContext(usageContext))){
|
||||
usageContext.getWorld().setBlockState(pos, containedFluid.getDefaultState().getBlockState());
|
||||
stack.decrement(1);
|
||||
usageContext.getPlayer().inventory.insertStack(getEmpty());
|
||||
insertOrDropStack(usageContext.getPlayer(), getEmpty());
|
||||
playEmptyingSound(usageContext.getPlayer(), usageContext.getWorld(), pos, containedFluid);
|
||||
}
|
||||
}
|
||||
return super.useOnBlock(usageContext);
|
||||
}
|
||||
|
||||
private void insertOrDropStack(PlayerEntity playerEntity, ItemStack stack){
|
||||
if(!playerEntity.inventory.insertStack(stack)){
|
||||
playerEntity.dropStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
//Thanks vanilla :)
|
||||
private void playEmptyingSound(@Nullable PlayerEntity playerEntity, IWorld world, BlockPos blockPos, Fluid fluid) {
|
||||
SoundEvent soundEvent = fluid.matches(FluidTags.LAVA) ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
|
||||
|
|
Loading…
Add table
Reference in a new issue