Jump to content

Recommended Posts

Posted

I am working on a mod and I wan't a plant to drop both the seeds and the fruit

Here is my code for the get item dropped

[embed=425,349]@Override

    public Item getItemDropped(int parMetadata, Random parRand, int parFortune) 

    {

        return (RA_Items.itemSpinachSeeds);

    } [/embed]

 

How would I make it return the itemSpinachSeeds and an ItemSpinach?

Posted

I replaced the previous code with

 

 

    @Override

    public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {

        ArrayList<ItemStack> drops = new ArrayList<ItemStack>();

        drops.add(new ItemStack(RA_Items.itemSpinachSeeds, world.rand.nextInt(3) + 1));

        drops.add(new ItemStack(RA_Items.itemSpinach, 1));

        return drops;

    }

 

however now it doesn't drop anything. I am missing something?

Posted

public class BlockSpinachPlant extends BlockCrops {

 

public String name = "BlockSpinachPlant";

//basic block properties

public BlockSpinachPlant()

{

this.setBlockName(name);

}

 

    @Override

    public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {

        ArrayList<ItemStack> drops = new ArrayList<ItemStack>();

        drops.add(new ItemStack(RA_Items.itemSpinachSeeds, world.rand.nextInt(3) + 1));

        drops.add(new ItemStack(RA_Items.itemSpinach, 1));

        return drops;

    }

   

    @Override

    @SideOnly(Side.CLIENT)

    public void registerBlockIcons(IIconRegister parIIconRegister)

    {

          iIcon = new IIcon[maxGrowthStage+1];

          // seems that crops like to have 8 growth icons, but okay to repeat actual texture if you want

          // to make generic should loop to maxGrowthStage

          iIcon[0] = parIIconRegister.registerIcon("ra:Coffee_stage_0");

          iIcon[1] = parIIconRegister.registerIcon("ra:Coffee_stage_1");

          iIcon[2] = parIIconRegister.registerIcon("ra:Coffee_stage_2");

          iIcon[3] = parIIconRegister.registerIcon("ra:Coffee_stage_3");

          iIcon[4] = parIIconRegister.registerIcon("ra:Coffee_stage_4");

          iIcon[5] = parIIconRegister.registerIcon("ra:Coffee_stage_5");

          iIcon[6] = parIIconRegister.registerIcon("ra:Coffee_stage_6");

          iIcon[7] = parIIconRegister.registerIcon("ra:Coffee_stage_7");

    }

}

 

and here is the BlockCrops class it implements

 

 

public class BlockCrops extends BlockBush implements IGrowable {

 

protected int maxGrowthStage = 7;

@SideOnly(Side.CLIENT)

protected IIcon[] iIcon;

 

public BlockCrops() {

// Basic block setup

setTickRandomly(true);

float f = 0.5F;

setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);

setCreativeTab(null);

setHardness(0.0F);

setStepSound(soundTypeGrass);

disableStats();

}

 

public boolean isOpaqueCube() {

return false;

// stops x-ray vision

}

 

 

    //is the block grass, dirt or farmland

    @Override

    protected boolean canPlaceBlockOn(Block parBlock)

    {

        return parBlock == Blocks.farmland;

    }

   

    public void incrementGrowStage(World parWorld, Random parRand, int parX, int parY, int parZ)

    {

        int growStage = parWorld.getBlockMetadata(parX, parY, parZ) +

              MathHelper.getRandomIntegerInRange(parRand, 2, 5);

 

        if (growStage > maxGrowthStage)

        {

        growStage = maxGrowthStage;

        }

 

        parWorld.setBlockMetadataWithNotify(parX, parY, parZ, growStage, 2);

    }

    @Override

    public Item getItemDropped(int metadata, Random parRand, int parFortune)

    {

        return Item.getItemFromBlock(this);

    }

   

   

    // The type of render function that is called for this block

    @Override

    public int getRenderType()

    {

        return 1; // Cross like flowers

    } 

 

//Gets the block's texture. Args: side, meta   

    @Override

    @SideOnly(Side.CLIENT)

    public IIcon getIcon(int parSide, int parGrowthStage)

    {

    return iIcon[parGrowthStage];

    }   

   

//grows automatically after a random amount of ticks

    @Override

    public void updateTick(World parWorld, int parX, int parY, int parZ, Random parRand)

    {   

        super.updateTick(parWorld, parX, parY, parZ, parRand);

        int growStage = parWorld.getBlockMetadata(parX, parY, parZ) + 1;

 

        if (growStage > 7)

        {

            growStage = 7;

        }

 

        parWorld.setBlockMetadataWithNotify(parX, parY, parZ, growStage, 2);

    }

   

   

    // checks if finished growing (a grow stage of 7 is final stage)

    @Override   

    public boolean func_149851_a(World world, int parX, int parY, int parZ,

            boolean allowed)

      {

          return world.getBlockMetadata(parX, parY, parZ) != 7;

          //checks if bonemeal is allowed

      }

 

 

      @Override

      public boolean func_149852_a(World world, Random parRand, int parX, int parY,

              int parZ)

      {

          return true;

      }

 

 

      @Override

      public void func_149853_b(World world, Random rand, int parX, int parY,

            int parZ)

      {

          incrementGrowStage(world, rand, parX, parY, parZ);

      }

      /*

        func_149851_a returns true if bonemeal is allowed, false otherwise.

func_149852_a returns true at the same time bonemeal is used if conditions for a growth-tick are acceptable.

func_149853_b processes the actual growth-tick logic, which is usually increasing metadata or replacing the block.

      */

     

      @Override

      public boolean canBlockStay (World world, int x, int y, int z) {

          Block soil = world.getBlock(x, y - 1, z);

          return (world.getFullBlockLightValue(x, y, z) >= 8 ||

                  world.canBlockSeeTheSky(x, y, z)) &&

                  (soil != null && soil.canSustainPlant(world, x, y - 1, z,

                        ForgeDirection.UP, (IPlantable) RA_Items.itemCoffeeBeans));

      }

}

 

Posted

I am. Here is the code.

 

public final class RA_Blocks {

 

public static final Block blockCoffeePlant = new BlockCoffeePlant();

public static final Block blockSpinachPlant = new BlockSpinachPlant();

 

public static void initBlocks() {

 

GameRegistry.registerBlock(blockCoffeePlant, blockCoffeePlant.getUnlocalizedName().substring(5));

GameRegistry.registerBlock(blockSpinachPlant, blockSpinachPlant.getUnlocalizedName().substring(5));

 

}

 

}

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

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

×
×
  • Create New...

Important Information

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