Posted October 23, 20159 yr I want to make crop that grows, then grows a fruit and once the fruit is grown it can pick leaving the plant to more fruit, like the natura bush.
October 23, 20159 yr Soooo a block that has growth metadata that drops fruit when right-clicked at max metadata and at that point also resets itself to 0? Only at all tricky part would be incrementing said data, I'd think. If anyone has a comprehensive, visual guide to GUIs - don't hesitate to message me. They make my head spin.
October 23, 20159 yr Try this: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-creating-custom.html
October 25, 20159 yr basically you just have to make a block class extending the crop block. then override the onactivation/on right click method where it sets itself to the specific plant stage (metadata) of where its about to generate the harvestable crop and give it to the player. that is pretty much it.
October 26, 20159 yr Author Try this: http://jabelarminecraft.blogspot.com/p/minecraft-forge-172-creating-custom.html I found this doing a search myself, and yes it help with crop like wheat I had to do some custom to get the meta to reset to click but i have two problems the texture do not load and there lots of ghost fruit. Here my code if you can help fix them bugs: The fruit: package dijkstra.jaffa.crops; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.ItemFood; public class Orange extends ItemFood{ public Orange() { super(3, 4f, false); this.setUnlocalizedName("orange"); this.setCreativeTab(CreativeTabs.tabFood); this.setTextureName("jaffa:orange"); } } The plant: package dijkstra.jaffa.crops; import java.awt.Color; import java.util.Random; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import dijkstra.jaffa.items.Items; import net.minecraft.block.Block; import net.minecraft.block.BlockBush; import net.minecraft.block.IGrowable; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; import net.minecraftforge.common.IPlantable; public class OrangePlant extends BlockBush implements IGrowable { protected int maxGrowthStage = 7; @SideOnly(Side.CLIENT) protected IIcon[] iIcon; public OrangePlant() { setBlockName("orangeBush"); //setBlockTextureName("jaffa:orange"); setTickRandomly(true); float f = 0.5F; setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f); setCreativeTab(CreativeTabs.tabFood); setHardness(0.0F); setStepSound(soundTypeGrass); disableStats(); } @Override protected boolean canPlaceBlockOn(Block b) { return b == Blocks.farmland; } @Override public Item getItemDropped(int m, Random r, int f) { return Items.items.get("orangeSeeds"); } @Override public int getRenderType() { return 6; } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(int s, int g) { this.blockIcon = iIcon[g]; return iIcon[g]; } @Override public boolean func_149851_a(World parWorld, int parX, int parY, int parZ, boolean p_149851_5_) { return parWorld.getBlockMetadata(parX, parY, parZ) != maxGrowthStage; } @Override public boolean func_149852_a(World w, Random r, int p_149852_3_, int p_149852_4_, int p_149852_5_) { return true; } @Override public void func_149853_b(World w, Random r, int x, int y, int z) { int growStage = w.getBlockMetadata(x, y, z) + MathHelper.getRandomIntegerInRange(r, 2, 5); if (growStage > maxGrowthStage) { growStage = maxGrowthStage; } w.setBlockMetadataWithNotify(x, y, z, growStage, 2); } @Override public void updateTick(World w, int x, int y, int z, Random r) { super.updateTick(w, x, y, y, r); int growStage = w.getBlockMetadata(x, y, z) + 1; if (growStage > maxGrowthStage) { growStage = maxGrowthStage; } w.setBlockMetadataWithNotify(x, y, z, growStage, 2); } @Override public int quantityDropped(int m, int f, Random r) { return r.nextInt(3)+1; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister icon) { iIcon = new IIcon[maxGrowthStage+1]; for (int i = 0; i < this.iIcon.length; ++i) { this.iIcon[i] = icon.registerIcon("jaffa:orange_stage_" + i); } } @Override public boolean onBlockActivated(World w, int x, int y, int z, EntityPlayer p, int side, float subX, float subY, float subZ) { if(w.getBlockMetadata(x, y, z) == maxGrowthStage){ ItemStack is = new ItemStack(Items.items.get("orange"), new Random().nextInt(3)+1); EntityItem orange = new EntityItem(w, x, y, z, is); w.spawnEntityInWorld(orange); w.setBlockMetadataWithNotify(x, y, z, maxGrowthStage - 5, 2); return true; } return false; } } The Seeds: package dijkstra.jaffa.crops; import net.minecraft.block.Block; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.EnumPlantType; import net.minecraftforge.common.IPlantable; import net.minecraftforge.common.util.ForgeDirection; public class OrangeSeeds extends Item implements IPlantable { private final Block theBlockPlant; private final Block soilId; public OrangeSeeds() { setUnlocalizedName("orangeSeeds"); setTextureName("jaffa:orangeSeeds"); setCreativeTab(CreativeTabs.tabFood); theBlockPlant = dijkstra.jaffa.blocks.Blocks.blocks.get("orangePlant"); soilId = Blocks.farmland; } @Override public boolean onItemUse(ItemStack i, EntityPlayer p, World w, int x, int y, int z, int p7, float p8, float p9, float p10) { if (p7 != 1) { return false; } else if (p.canPlayerEdit(x, y+1, z, p7, i)) { if (w.getBlock(x, y, z).canSustainPlant(w, x, y, z, ForgeDirection.UP, this) && w.isAirBlock(x, y+1, z)) { w.setBlock(x, y+1, z, theBlockPlant); --i.stackSize; return true; } else { return false; } } else { return false; } } @Override public EnumPlantType getPlantType(IBlockAccess w, int x, int y, int z) { return EnumPlantType.Crop; } @Override public Block getPlant(IBlockAccess w, int x, int y, int z) { return theBlockPlant; } @Override public int getPlantMetadata(IBlockAccess w, int x, int y, int z) { return 0; } public Block getSoilId() { return soilId; } }
October 26, 20159 yr Only drop items on the server. 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.
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.