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));
}
}
}
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);
}
}
Aggregations