use of net.minecraft.block.ILiquidContainer in project MCMOD-Industria by M-Marvin.
the class ItemFluidCannister method emptyBucket.
/**
* Modified vanilla bucket behavior
*/
@SuppressWarnings("deprecation")
public boolean emptyBucket(@Nullable PlayerEntity player, World world, BlockPos pos, @Nullable BlockRayTraceResult raytraceResult, Fluid content) {
BlockState blockstate = world.getBlockState(pos);
Block block = blockstate.getBlock();
Material material = blockstate.getMaterial();
boolean flag = blockstate.canBeReplaced(content);
boolean flag1 = blockstate.isAir() || flag || block instanceof ILiquidContainer && ((ILiquidContainer) block).canPlaceLiquid(world, pos, blockstate, content);
if (!flag1) {
return raytraceResult != null && this.emptyBucket(player, world, raytraceResult.getBlockPos().relative(raytraceResult.getDirection()), (BlockRayTraceResult) null, content);
} else if (world.dimensionType().ultraWarm() && !canPlaceInNether(content)) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
world.playSound(player, pos, SoundEvents.FIRE_EXTINGUISH, SoundCategory.BLOCKS, 0.5F, 2.6F + (world.random.nextFloat() - world.random.nextFloat()) * 0.8F);
for (int l = 0; l < 8; ++l) {
world.addParticle(ParticleTypes.LARGE_SMOKE, (double) i + Math.random(), (double) j + Math.random(), (double) k + Math.random(), 0.0D, 0.0D, 0.0D);
}
return true;
} else if (block instanceof ILiquidContainer && ((ILiquidContainer) block).canPlaceLiquid(world, pos, blockstate, content)) {
((ILiquidContainer) block).placeLiquid(world, pos, blockstate, ((FlowingFluid) content).getSource(false));
return true;
} else {
if (!world.isClientSide && flag && !material.isLiquid()) {
world.destroyBlock(pos, true);
}
if (!world.setBlock(pos, content.defaultFluidState().createLegacyBlock(), 11) && !blockstate.getFluidState().isSource()) {
return false;
} else {
return true;
}
}
}
use of net.minecraft.block.ILiquidContainer in project MCMOD-Industria by M-Marvin.
the class ItemFluidBucket method emptyBucket.
@SuppressWarnings("deprecation")
public boolean emptyBucket(@Nullable PlayerEntity player, World worldIn, BlockPos posIn, @Nullable BlockRayTraceResult rayTrace) {
if (!(getFluid() instanceof FlowingFluid)) {
return false;
} else {
BlockState blockstate = worldIn.getBlockState(posIn);
Block block = blockstate.getBlock();
Material material = blockstate.getMaterial();
boolean flag = blockstate.canBeReplaced(getFluid());
boolean flag1 = blockstate.isAir() || flag || block instanceof ILiquidContainer && ((ILiquidContainer) block).canPlaceLiquid(worldIn, posIn, blockstate, getFluid());
if (!flag1) {
return rayTrace != null && this.emptyBucket(player, worldIn, rayTrace.getBlockPos().relative(rayTrace.getDirection()), (BlockRayTraceResult) null);
} else if (!canPlaceInNether && worldIn.dimensionType().ultraWarm()) {
int i = posIn.getX();
int j = posIn.getY();
int k = posIn.getZ();
worldIn.playSound(player, posIn, SoundEvents.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);
}
return true;
} else if (block instanceof ILiquidContainer && ((ILiquidContainer) block).canPlaceLiquid(worldIn, posIn, blockstate, getFluid())) {
((ILiquidContainer) block).placeLiquid(worldIn, posIn, blockstate, ((FlowingFluid) getFluid()).getSource(false));
this.playEmptySound(player, worldIn, posIn);
return true;
} else {
if (!worldIn.isClientSide && flag && !material.isLiquid()) {
worldIn.destroyBlock(posIn, true);
}
if (!worldIn.setBlock(posIn, getFluid().defaultFluidState().createLegacyBlock(), 11) && !blockstate.getFluidState().isSource()) {
return false;
} else {
this.playEmptySound(player, worldIn, posIn);
return true;
}
}
}
}
use of net.minecraft.block.ILiquidContainer in project MCMOD-Industria by M-Marvin.
the class ItemGasBucket method emptyBucket.
@SuppressWarnings("deprecation")
public boolean emptyBucket(@Nullable PlayerEntity player, World worldIn, BlockPos posIn, @Nullable BlockRayTraceResult p_180616_4_) {
BlockState blockstate = worldIn.getBlockState(posIn);
Block block = blockstate.getBlock();
Material material = blockstate.getMaterial();
boolean flag = blockstate.canBeReplaced(this.getFluid());
boolean flag1 = blockstate.isAir() || flag || block instanceof ILiquidContainer && ((ILiquidContainer) block).canPlaceLiquid(worldIn, posIn, blockstate, this.getFluid());
if (!flag1) {
return p_180616_4_ != null && this.emptyBucket(player, worldIn, p_180616_4_.getBlockPos().relative(p_180616_4_.getDirection()), (BlockRayTraceResult) null);
} else if (worldIn.dimensionType().ultraWarm() && this.getFluid().is(FluidTags.WATER)) {
int i = posIn.getX();
int j = posIn.getY();
int k = posIn.getZ();
worldIn.playSound(player, posIn, SoundEvents.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);
}
return true;
} else if (block instanceof ILiquidContainer && ((ILiquidContainer) block).canPlaceLiquid(worldIn, posIn, blockstate, getFluid())) {
((ILiquidContainer) block).placeLiquid(worldIn, posIn, blockstate, ((FlowingFluid) this.getFluid()).getSource(false));
this.playEmptySound(player, worldIn, posIn);
return true;
} else {
if (!worldIn.isClientSide && flag && !material.isLiquid()) {
worldIn.destroyBlock(posIn, true);
}
if (!worldIn.setBlock(posIn, this.getFluid().defaultFluidState().createLegacyBlock(), 11) && !blockstate.getFluidState().isSource()) {
return false;
} else {
this.playEmptySound(player, worldIn, posIn);
return true;
}
}
}
Aggregations