Search in sources :

Example 1 with WorldAccess

use of net.minecraft.world.WorldAccess in project Rug by RubixDev.

the class WorldMixin method convertBasalt.

@Inject(method = "setBlockState(Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;II)Z", at = @At("HEAD"), cancellable = true)
private void convertBasalt(BlockPos pos, BlockState state, int flags, int maxUpdateDepth, CallbackInfoReturnable<Boolean> cir) {
    if (state.isOf(Blocks.BASALT)) {
        BlockState prevState = ((BlockView) this).getBlockState(pos);
        if (FluidHelper.shouldConvertToLava((BlockView) this, pos)) {
            if (prevState.isOf(Blocks.LAVA) && prevState.getFluidState().isStill()) {
                cir.setReturnValue(false);
                return;
            }
            FluidHelper.playFizzleSound((WorldAccess) this, pos);
            ((WorldAccess) this).playSound(null, pos, SoundEvents.ITEM_BUCKET_EMPTY_LAVA, SoundCategory.BLOCKS, 1.0F, 1.0F);
            cir.setReturnValue(this.setBlockState(pos, Blocks.LAVA.getDefaultState(), flags, maxUpdateDepth));
        }
    }
}
Also used : BlockView(net.minecraft.world.BlockView) WorldAccess(net.minecraft.world.WorldAccess) BlockState(net.minecraft.block.BlockState) Inject(org.spongepowered.asm.mixin.injection.Inject)

Example 2 with WorldAccess

use of net.minecraft.world.WorldAccess in project Rug by RubixDev.

the class PillarBlockMixin method convertBasalt.

@Inject(method = "getPlacementState", at = @At("HEAD"), cancellable = true)
private void convertBasalt(ItemPlacementContext ctx, CallbackInfoReturnable<BlockState> cir) {
    WorldAccess world = ctx.getWorld();
    BlockPos pos = ctx.getBlockPos();
    if (this == Blocks.BASALT && FluidHelper.shouldConvertToBlackstone(world, pos)) {
        cir.setReturnValue(Blocks.BLACKSTONE.getDefaultState());
        FluidHelper.playFizzleSound(world, pos);
    }
}
Also used : WorldAccess(net.minecraft.world.WorldAccess) BlockPos(net.minecraft.util.math.BlockPos) Inject(org.spongepowered.asm.mixin.injection.Inject)

Aggregations

WorldAccess (net.minecraft.world.WorldAccess)2 Inject (org.spongepowered.asm.mixin.injection.Inject)2 BlockState (net.minecraft.block.BlockState)1 BlockPos (net.minecraft.util.math.BlockPos)1 BlockView (net.minecraft.world.BlockView)1