use of net.minecraft.fluid.FlowableFluid in project Paradise-Lost by devs-immortal.
the class SkyrootBucket method placeLiquid.
public boolean placeLiquid(PlayerEntity playerIn, World worldIn, BlockPos posIn, BlockHitResult hitResult) {
if (!(this.containedBlock instanceof FlowableFluid)) {
return false;
} else {
BlockState stateIn = worldIn.getBlockState(posIn);
Material material = stateIn.getMaterial();
boolean flag = !material.isSolid();
boolean flag1 = material.isReplaceable();
if (worldIn.isAir(posIn) || flag || flag1 || stateIn.getBlock() instanceof FluidFillable && ((FluidFillable) stateIn.getBlock()).canFillWithFluid(worldIn, posIn, stateIn, this.containedBlock)) {
if (worldIn.getRegistryKey().equals(World.NETHER)) {
int i = posIn.getX();
int j = posIn.getY();
int k = posIn.getZ();
worldIn.playSound(playerIn, posIn, SoundEvents.BLOCK_FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (worldIn.random.nextFloat() - worldIn.random.nextFloat()) * 0.8F);
for (int l = 0; l < 8; ++l) {
worldIn.addParticle(ParticleTypes.LARGE_SMOKE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
}
} else if (stateIn.getBlock() instanceof FluidFillable) {
if (((FluidFillable) stateIn.getBlock()).tryFillWithFluid(worldIn, posIn, stateIn, ((FlowableFluid) this.containedBlock).getStill(false))) {
this.playEmptySound(playerIn, worldIn, posIn);
}
} else {
if (!worldIn.isClient && (flag || flag1) && !material.isLiquid()) {
worldIn.breakBlock(posIn, true);
}
this.playEmptySound(playerIn, worldIn, posIn);
worldIn.setBlockState(posIn, this.containedBlock.getDefaultState().getBlockState(), 11);
}
return true;
} else {
return hitResult != null && this.placeLiquid(playerIn, worldIn, hitResult.getBlockPos().offset(hitResult.getSide()), null);
}
}
}
Aggregations