Jump to content

Recommended Posts

Posted

Hello.

I have made a sweet berry bush block, and I'm trying to change its drop from Items.SWEET_BERRIES to Registry.BLUEBERRY.get(). For some reason, this isn't working in game.

Here's my code:

package com.pickleface.survival.blocks;

import com.pickleface.survival.Registry;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;

public class BlueberryBush extends SweetBerryBushBlock {
    public BlueberryBush() {
        super(Block.Properties.create(Material.PLANTS)
                .tickRandomly()
                .doesNotBlockMovement()
                .sound(SoundType.SWEET_BERRY_BUSH)
                .zeroHardnessAndResistance()
        );
    }
    @Override
    public ItemStack getItem(IBlockReader block, BlockPos pos, BlockState state) {
        return new ItemStack(Registry.BLUEBERRY.get());
    }
}

The part that controls its drops is at the Override. Also, I get 2 warnings saying "Not annotated method overrides method annotated with @MethodsReturnNonnullByDefault" and "Not annotated parameters overrides @ParametersNonnullByDefault".

 

Any help is appreciated. Thanks.

Have some lorem ispum.

Posted

Sounds like you haven't correctly overridden the method. That is, the original has an annotation that is IMPORTANT that you have not annotated your override with.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted
32 minutes ago, Pickle_Face5 said:

The part that controls its drops is at the Override.

If I'm not wrong, you actually need to override the method onBlockActivated as well. Just keep it identical as vanilla and replace the Sweetberry Item in spawnAsEntity with your blue berry. I did this in my own Blueberry bush and it's working just fine!

 

Posted
Just now, Talp1 said:

If I'm not wrong, you actually need to override the method onBlockActivated as well. Just keep it identical as vanilla and replace the Sweetberry Item in spawnAsEntity with your blue berry. I did this in my own Blueberry bush and it's working just fine!

 

Thanks, it works now! 🎉

Have some lorem ispum.

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.