net.minecraft.block.FluidDrainable Java Examples

The following examples show how to use net.minecraft.block.FluidDrainable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BaseFluidMixin.java    From Galacticraft-Rewoven with MIT License 5 votes vote down vote up
@Redirect(method = "onScheduledTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;I)Z"))
private boolean onScheduledTickGC(World world, BlockPos pos, BlockState state, int flags) {
    if (world.getBlockState(pos).getBlock() instanceof FluidDrainable && world.getBlockState(pos).getBlock() instanceof FluidFillable) {
        if (state.isAir()) {
            ((FluidDrainable) world.getBlockState(pos).getBlock()).tryDrainFluid(world, pos, world.getBlockState(pos));
            return true;
        } else {
            ((FluidDrainable) world.getBlockState(pos).getBlock()).tryDrainFluid(world, pos, world.getBlockState(pos));
            ((FluidFillable) world.getBlockState(pos).getBlock()).tryFillWithFluid(world, pos, world.getBlockState(pos), state.getFluidState());
            return true;
        }
    }
    return world.setBlockState(pos, state, flags);
}