Posted February 13, 20205 yr so i want to make it so when i right click mossycobble(vanilla block) by my custom item it changes to cobble and drops another custom item, i know i have to use onItemUse but i am new to java. Thnx in advance
February 13, 20205 yr Author ohh yeah figured it out @Override public ActionResultType onItemUse(ItemUseContext context) { World world = context.getWorld(); BlockPos pos = context.getPos(); PlayerEntity playerIn = context.getPlayer(); ItemStack item = context.getItem(); Hand handIn = context.getHand(); if (!world.isRemote && world.getBlockState(pos).getBlock() == Blocks.MOSSY_COBBLESTONE) { (( ServerWorld)world).setBlockState(pos, Blocks.COBBLESTONE.getDefaultState()); item.damageItem(1, playerIn, (entity) -> {entity.sendBreakAnimation(handIn);;}); playerIn.inventory.addItemStackToInventory(new ItemStack(ItemInit.moss)); } return super.onItemUse(context); }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.