use of net.minecraft.world.BlockView 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.BlockView in project fabric by FabricMC.
the class PickBlockEventModClient method onInitializeClient.
@Override
public void onInitializeClient() {
ClientPickBlockGatherCallback.EVENT.register((player, result) -> {
if (result instanceof BlockHitResult) {
BlockView view = player.getEntityWorld();
BlockPos pos = ((BlockHitResult) result).getBlockPos();
BlockState state = view.getBlockState(pos);
if (state.getBlock() == Blocks.STONE) {
return new ItemStack(Blocks.OAK_WOOD);
}
}
return ItemStack.EMPTY;
});
ClientPickBlockApplyCallback.EVENT.register((player, result, stack) -> {
if (stack.getItem() == Item.getItemFromBlock(Blocks.OAK_WOOD)) {
return new ItemStack(Blocks.ACACIA_WOOD);
} else {
return stack;
}
});
}
Aggregations