Posted April 19, 201411 yr I have just created a crop(strawberry plant) but the only way to get the drops from the fully grown crop is to destroy the dirt under it. How can I fix this? Crop class: package com.puplet.blocks; import java.util.Random; import com.puplet.items.PupletItems; import net.minecraft.block.BlockCrops; import net.minecraft.init.Items; import net.minecraft.item.Item; public class PupletCrop extends BlockCrops{ /** * seeds */ @Override protected Item func_149866_i() { return PupletItems.pupletSeeds; } /** * crop */ @Override protected Item func_149865_P() { return PupletItems.Strawberry; } } Don't tell me to learn the basics of java, I already know.
April 19, 201411 yr Don't know. Maybe you have to override the method that checks if the metadata is 7 when you break it - then drops the item.
April 20, 201411 yr Hi Do you mean - you can't destroy the crop by clicking on it? Or do you mean- if you destroy the block by clicking on it, it gives you nothing? You have to use the appropriate tool to harvest a crop... The code from 1.6.4 has a couple of relevant functions in it, you could perhaps find the corresponding ones in 1.7.2, place a breakpoint in them, and see why you're not getting strawberries. Alternatively a breakpoint in Block.harvestBlock and/or ItemInWorldManager.tryHarvestBlock will also narrow things down a lot. -TGG @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); if (metadata >= 7) { for (int n = 0; n < 3 + fortune; n++) { if (world.rand.nextInt(15) <= metadata) { ret.add(new ItemStack(this.getSeedItem(), 1, 0)); } } } return ret; } /** * Returns the ID of the items to drop on destruction. */ public int idDropped(int par1, Random par2Random, int par3) { return par1 == 7 ? this.getCropItem() : this.getSeedItem(); }
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.