Jump to content

[1.16.5] Replace Bock x with Block y


TamsynnImogen

Recommended Posts

hi im trying to get it so that when i use bonemeal on soul soil it turns into ferilized soul soil

i can get it so when i use bone meal on any block it changes to fertilized soul soil but as as soon as i try to restrict it to only soul soil it stops working

@SubscribeEvent public void onSoulSoilClick(PlayerInteractEvent.RightClickBlock e) { World world = e.getWorld(); PlayerEntity player = e.getPlayer(); ItemStack hand = e.getItemStack(); BlockPos targetpos = e.getPos(); BlockState state = world.getBlockState(targetpos); Block block = state.getBlock(); if (world.isRemote) { return; } if (!hand.getItem().equals(Items.BONE_MEAL)) { return; } if (block.equals(Blocks.SOUL_SOIL)) { world.setBlockState(targetpos, ModBlocks.FERTILE_SOUL_SOIL.get().getDefaultState()); } }

       @SubscribeEvent
    public void onSoulSoilClick(PlayerInteractEvent.RightClickBlock e) {
        World world = e.getWorld();
        PlayerEntity player = e.getPlayer();
        ItemStack hand = e.getItemStack();
        BlockPos targetpos = e.getPos();
        BlockState state = world.getBlockState(targetpos);
        Block block = state.getBlock();
        if (world.isRemote) {
            return;
        }
        if (!hand.getItem().equals(Items.BONE_MEAL)) {
            return;
        }
        if (block.equals(Blocks.SOUL_SOIL)) {
            world.setBlockState(targetpos, ModBlocks.FERTILE_SOUL_SOIL.get().getDefaultState());
        }
        if (!player.isCreative()) {
            hand.shrink(1);
        }
        }

 

Edited by TamsynnImogen
Link to comment
Share on other sites

the fertilized soul soil allows crops to grow on it. original plan was to get soul soil to be tillable and then get it so it acts like farmland but needing lava instead of water but couldnt figure out how to get it to be tillable so changed the plan and got it so you craft it with bone meal to make it fertilized and that'll take over wich worked but thought would be more fun to have it instead of a crafting recipe to get it done in world sortta thing

Link to comment
Share on other sites

oh ok

well ive fixed it anyway all it was instead of

 

if (block.equals(Blocks.SOUL_SOIL))

i used

if (block == (Blocks.SOUL_SOIL))

and it works (probably could remove the brackes around Blocks.SOUL_SOIL but was just a v quick test

 

i'll look into what you susgested later though as its probably better but for now im just glad it worked

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.