Jump to content

How do I add a drop to leaves ?


Irhala

Recommended Posts

Is there a way to add drops to leaves ? I'm trying to make them drop some sticks sometimes.

I found a forge method to add drops to tall grass, MinecraftForge.addGrassSeed(...), but I didn't found the same for leaves.

 

I don't want to change base class files ._.

 

Thanks for your help  ;)

Link to comment
Share on other sites

Then, you should just look under minecraft's leaves, see how they do the "droprate" for their items as well as whatever else you need, and modify their code as you need to. Sorry, if this isn't what you want, I have trouble understanding lots of people. :P

Link to comment
Share on other sites

Then, you should just look under minecraft's leaves, see how they do the "droprate" for their items as well as whatever else you need, and modify their code as you need to. Sorry, if this isn't what you want, I have trouble understanding lots of people. :P

No, he just needs an event handler. If he does it like that he needs to make it a coremod, and nobody wants to make their mod a coremod if they don't have to.

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

there are forge events (like this), but as far as i can tell there isn't one which is called when the block is broken (see full list). Someone correct me if i'm wrong, but after a few Google searches all I've found are people asking why there isn't one.

 

Ah. Well, I get it now. :P Hmm.... Could you make a class that extended the leaf drops?

 

that probably wouldn't work. Your class wouldn't be called when the block was broken unless you overwrote some vanilla code, which is something i guess you already know you don't want to do.

 

You could, possibly, try doing something like the following where you register your blocks:

Block.blocksList[block.leaves.blockID] = null;
myLeaves = new BlockMyLeaves(Block.leaves.blockID); //BlockMyLeaves being your extension of BlockLeaves and myLeaves being the block name

 

not sure how well that will work, but it could be worth a shot.

 

good luck :)

Link to comment
Share on other sites

You could, possibly, try doing something like the following where you register your blocks:

Code: [select]

Block.blocksList[block.leaves.blockID] = null;

myLeaves = new BlockMyLeaves(Block.leaves.blockID); //BlockMyLeaves being your extension of BlockLeaves and myLeaves being the block name

 

not sure how well that will work, but it could be worth a shot.

 

Wouldn't this be useful if I were using my own Leaves, not vanilla's leaves ?

Link to comment
Share on other sites

you create a class which extends BlockLeaves, this class has all the properties of BlockLeaves. Then be removing the vanilla block form the array and replacing it with your block you cause your block to be generated whenever the vanilla leaves would have been. You can then override the drops so that it drops sticks as well as saplings.

 

P.S you will need to override the drops as follows so that the probability of saplings does not change:

    @Override
    public ArrayList<ItemStack> getBlockDropped(World world, int x, int y, int z, int metadata, int fortune)
    {
        ArrayList<ItemStack> ret = super.getBlockDropped(world, x, y, z, metadata, fortune);
        ret.add(new ItemStack(Item.stick.itemID, 1));
        return ret;
    }

Link to comment
Share on other sites

shouldn't cause too much incompatibility. Most mods which reference leaves will be doing it by Block.leaves.blockID, which is the same as our blockID, or by if(block instanceof BlockLeaves) which is true for our block also as it extends BlockLeaves. A problem may occur if they do if(block.class == BlockLeaves.Class) but this wouldn't be anything critical, and i think should be fairly uncommon.

Link to comment
Share on other sites

But if you're able to make the BlockMyLeaves extension work, i'd be grateful, because it would teach me so much more :)

I'd be able to use it for other parts of Minecraft, especially the block breaking system (no longer tree-punching !)

Link to comment
Share on other sites

But if you're able to make the BlockMyLeaves extension work, i'd be grateful, because it would teach me so much more :)

I'd be able to use it for other parts of Minecraft, especially the block breaking system (no longer tree-punching !)

Create your BlockMyLeaves extends BlockLeaves, then put this in your @Init:

Block.blocksList[blockLeaves.blockID] = new BlockMyLeaves();

BEWARE OF GOD

---

Co-author of Pentachoron Labs' SBFP Tech.

Link to comment
Share on other sites

Create your BlockMyLeaves extends BlockLeaves, then put this in your @Init:

Block.blocksList[blockLeaves.blockID] = new BlockMyLeaves();

 

 

argh!! not like that!

you will get a problem with

if (blocksList[par1] != null)
        {
            throw new IllegalArgumentException("Slot " + par1 + " is already occupied by " + blocksList[par1] + " when adding " + this);
        }

in the block constructor. Hence i did it how i posted.

Block.blocksList[block.leaves.blockID] = null;
myLeaves = new BlockMyLeaves(Block.leaves.blockID); //BlockMyLeaves being your extension of BlockLeaves and myLeaves being the block name

 

then the constructor for your block will put it into the array.

Link to comment
Share on other sites

I tried, but when I create the constructor (either as public or protected)

protected BlockMyLeaves(int par1) {
	super(par1);
}

It tells me to add a BlockMyLeaves(int) constructor, and when i click on it, it creates the same one -.-

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Post logs as per https://forums.minecraftforge.net/topic/125488-rules-and-frequently-asked-questions-faq/ They may have information that will answer these questions.
    • I was left reeling when a glitch on a cryptocurrency exchange caused me to lose $166,000 worth of my hard-earned savings. It felt like my entire world had crumbled in the blink of an eye, leaving me with a sense of hopelessness. Determined not to give up, I delved into research on recovery options, unsure of what to expect. That's when I stumbled upon I was left reeling when a glitch on a cryptocurrency exchange caused me to lose $166,000 worth of my hard-earned savings. It felt like my entire world had crumbled in the blink of an eye, leaving me with a sense of hopelessness. Determined not to give up, I delved into research on recovery options, unsure of what to expect. That's when I stumbled upon DIGITAL HACK RECOVERY, a beacon of hope in my darkest hour. Despite my initial doubts, I decided to take a leap of faith and give them a shot as a final lifeline. The experts at DIGITAL HACK RECOVERY proved to be masters of their craft, guiding me through their exclusive process with precision and expertise. Utilizing cutting-edge blockchain analysis methods, they were able to track down the elusive trail of my missing funds and identify the exact point of failure. Their forensic talents were unparalleled as they tirelessly combed through the intricate web of blockchain data to locate my cryptocurrency. With each step they took, they kept me informed of their progress, never wavering in their belief that my funds could be rescued. After several painstaking weeks, DIGITAL HACK RECOVERY finally located and restored my $166,000 worth of cryptocurrency. I was awestruck that they were able to salvage what I had thought was lost forever. The whole experience restored my faith in the crypto space and proved that even in the worst situations, recovery is possible with the right experts on your side. I will be forever grateful to DIGITAL HACK RECOVERY for giving me back my life savings when I needed it most. Their tireless efforts and technical mastery turned what could have been a devastating loss into an uplifting success story. Book a time with DIGITAL HACK RECOVERY through: digital hack recovery @ techie . com &  +12018871705
    • public class ParticleReboundRecipe implements Recipe<CraftingContainer> { private List<ParticleReboundIngredient> inputs; private ParticleReboundFuel fuel; private ItemStack output; public ParticleReboundRecipe(List<ParticleReboundIngredient> inputs, ParticleReboundFuel fuel, ItemStack output) { this.inputs = inputs; this.fuel = fuel; this.output = output; } // TODO: Implement interface ... // TODO: Move to separate file if desired public record ParticleReboundIngredient(Ingredient ingredient, int count) { public static final Codec<ParticleReboundIngredient> CODEC = RecordCodecBuilder.create( builder -> builder.group( Ingredient.CODEC.fieldOf("ingredient").forGetter((i) -> i.ingredient), Codec.INT.fieldOf("count").forGetter(i -> i.count) ).apply(builder, ParticleReboundIngredient::new) ); } // TODO: Move to separate file if desired public record ParticleReboundFuel(String tag) { public static final Codec<ParticleReboundFuel> CODEC = RecordCodecBuilder.create( builder -> builder.group(Codec.STRING.fieldOf("tag").forGetter(f -> f.tag)).apply(builder, ParticleReboundFuel::new) ); public boolean isFuel(ItemStack stack) { // TODO: Check if fuel item matches the tag } } public class Serializer implements RecipeSerializer<ParticleReboundRecipe> { public static final Codec<ParticleReboundRecipe> CODEC = RecordCodecBuilder.create( builder -> builder.group( ParticleReboundIngredient.CODEC.listOf().fieldOf("inputs").forGetter(r -> r.inputs), ParticleReboundFuel.CODEC.fieldOf("fuel").forGetter(r -> r.fuel), ItemStack.CODEC.fieldOf("output").forGetter(r -> r.output) ).apply(builder, ParticleReboundRecipe::new) ); @Override public @NotNull Codec<ParticleReboundRecipe> codec() { return CODEC; } // TODO: The rest ... } }   ?
    • I'm sure load and SaveAdditional are what you are looking for, probably. Mind sharing your BE class code? You also need to override onLoad method if you haven't
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

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