use of net.minecraft.world.level.material.FlowingFluid in project pollen by MoonflowerTeam.
the class BucketItemBase method emptyBucket.
@Override
public boolean emptyBucket(@Nullable Player player, Level level, BlockPos blockPos, @Nullable BlockHitResult blockHitResult) {
Fluid content = this.getFluid();
if (!(content instanceof FlowingFluid))
return false;
BlockState blockState = level.getBlockState(blockPos);
Block block = blockState.getBlock();
Material material = blockState.getMaterial();
boolean bl = blockState.canBeReplaced(content);
boolean bl2 = blockState.isAir() || bl || block instanceof LiquidBlockContainer && ((LiquidBlockContainer) block).canPlaceLiquid(level, blockPos, blockState, content);
if (!bl2) {
return blockHitResult != null && this.emptyBucket(player, level, blockHitResult.getBlockPos().relative(blockHitResult.getDirection()), null);
} else if (level.dimensionType().ultraWarm() && content.is(FluidTags.WATER)) {
int i = blockPos.getX();
int j = blockPos.getY();
int k = blockPos.getZ();
level.playSound(player, blockPos, SoundEvents.FIRE_EXTINGUISH, SoundSource.BLOCKS, 0.5F, 2.6F + (level.random.nextFloat() - level.random.nextFloat()) * 0.8F);
for (int l = 0; l < 8; ++l) {
level.addParticle(ParticleTypes.LARGE_SMOKE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0, 0.0, 0.0);
}
return true;
} else if (block instanceof LiquidBlockContainer && content == Fluids.WATER) {
((LiquidBlockContainer) block).placeLiquid(level, blockPos, blockState, ((FlowingFluid) content).getSource(false));
this.playEmptySound(player, level, blockPos);
return true;
} else {
if (!level.isClientSide() && bl && !material.isLiquid()) {
level.destroyBlock(blockPos, true);
}
if (!level.setBlock(blockPos, content.defaultFluidState().createLegacyBlock(), 11) && !blockState.getFluidState().isSource()) {
return false;
} else {
this.playEmptySound(player, level, blockPos);
return true;
}
}
}
use of net.minecraft.world.level.material.FlowingFluid in project MoreBoots by North-West-Wind.
the class Utils method isSurroundedByInvalidBlocks.
public static boolean isSurroundedByInvalidBlocks(LivingEntity player) {
BlockPos pos = new BlockPos(player.position());
BlockPos pos1 = pos.offset(1, 0, 1);
BlockPos pos2 = pos.offset(-1, 0, -1);
Iterator<BlockPos> iterator = BlockPos.betweenClosedStream(pos1, pos2).iterator();
while (iterator.hasNext()) {
BlockPos blockPos = iterator.next();
Block block = player.level.getBlockState(blockPos).getBlock();
Fluid fluid = player.level.getFluidState(blockPos).getType();
if (!player.level.isEmptyBlock(blockPos) && !(fluid instanceof FlowingFluid) && !block.getCollisionShape(player.level.getBlockState(blockPos), player.level, blockPos, CollisionContext.empty()).equals(Shapes.empty()))
return false;
}
return true;
}
Aggregations