Jump to content

need help with my Mod


Mark136

Recommended Posts

hello, i'm working on a flower that only can placed on (FarmField) a few of weeks but i'm stuck atm

 

@Override

protected boolean canThisPlantGrowOnThisBlockID(int i)

            {        

   

        return i == Mod_Mark136.FarmField.blockID;

    }

 

this should override the methode in the block flower class, but it does'nt, it combines

so you can also place my flower on grass/dirt/tilledfield, but i only want that it can be placed on the farmfield Block

 

can somebody help me?

(if you need more info, say what you need and i'll post it)

 

Mark136

 

 

 

 

my Mod: Extended RPG [W.I.P]

Link to comment
Share on other sites

I 'd like to say that you should Override your EnumPlantType to cave in your Seeds class.After this you can grow it everywhere.

 

 

@Override

    public EnumPlantType getPlantType(World world, int x, int y, int z)

    {

        return EnumPlantType.Cave;

    }

Link to comment
Share on other sites

it won't work, and it's not a seed but a flower/sapling

and i DON'T want to just place it everywhere, i only want my flower/sapling on my FarmField block

 

here is some codes from my modcorefile and my block flower.class , i dont write everything because i don't want to hurt your eyes.

look at it if you want

 

core mod file

 

****************

public static Block FarmField;

public static BlockMFlower Mark136Fl;

****************

public void load(FMLInitializationEvent ****)

****************

FarmField = new BlockMark136(191, 1, Material.rock).setStepSound(Block.soundStoneFootstep)    .setBlockName("Mark's Farm").setHardness(4.5F).setResistance(5F).setLightValue(0.25F);

 

Mark136Fl = (BlockMFlower) new BlockMFlower(204, 14).setStepSound(Block.soundGrassFootstep).setBlockName("Mark's flower") .setHardness(0.15F).setResistance(5F).setLightValue(0.375F);

****************

LanguageRegistry.addName(FarmField, "Mark's FarmField");

LanguageRegistry.addName(Mark136Fl, "Mark's Flower");

 

*************************************************

 

i think the BlockMark136.class is'nt interesting because it acts like a normal block

but the BlockMFlower.class maybe

 

 

package com.Mark136.ModMark136;

 

import java.util.Random;

 

import net.minecraft.src.Block;

import net.minecraft.src.BlockFlower;

import net.minecraft.src.CreativeTabs;

import net.minecraft.src.Material;

import net.minecraft.src.World;

 

 

public class BlockMFlower extends BlockFlower

{

 

    protected BlockMFlower(int par1, int par2)

    {

        super(par1, par2, Material.vine);

        float var3 = 0.4F;

        this.setBlockBounds(0.5F - var3, 0.0F, 0.5F - var3, 0.5F + var3, var3 * 2.0F, 0.5F + var3);

        this.setCreativeTab(CreativeTabs.tabDecorations);       

    }

   

            @Override

    protected boolean canThisPlantGrowOnThisBlockID(int i)

    {

        return i == Mod_Mark136.FarmField.blockID;

    }

   

    public int getBlockTextureFromSideAndMetadata(int par1, int par2)

    {

        return this.blockIndexInTexture;

    }

   

   

    public String getTextureFile()

    {

    return "/Mark136/Mark136Blocks.png" ;

   

    }

    public int quantityDropped(int par1)

    {

            return (1);

    }

 

    public int idDropped(int par1, Random par2Random, int par3)

    {

            return Mod_Mark136.Mark1361.shiftedIndex;

    }

my Mod: Extended RPG [W.I.P]

Link to comment
Share on other sites

Change "protected boolean canThisPlantGrowOnThisBlockID(int i)" to "public boolean canThisPlantGrowOnThisBlockID(int i)"

Protip: try and find answers yourself before asking on the forum.

It's pretty likely that there is an answer.

 

Was I helpful? Give me a thank you!

 

 

width=635 height=903http://bit.ly/HZ03zy[/img]

 

 

Tired of waiting for mods to port to bukkit?

use BukkitForge! (now with a working version of WorldEdit!)

Link to comment
Share on other sites

I see it.What you need to do is 2 things:

1.build a seed item extends ItemSeed.there will be ItemSeed(int,int,int),the first is itemID ,second is blockID of your crop,the 3rd is the soil blockID beneath it.in that class you should Override EnumPlantType to cave.

2.In blockyourcrop Class you should let canThisPlantGrowOnThisBlockID return your soil.

 

It works for me and I have many different plants that grows on plank,stone,etc.

Link to comment
Share on other sites

i dont want to create a seed item, i want a SAPLING please reed before answer

 

i want that my SAPLING can ONLY be planted on my block

 

can someone please help me with this

 

please give  no useless reactions

 

 

EDIT: i got it almost, i only need to get public EnumPlantType getPlantType(World world, int x, int y, int z)

return false, but i don't know how   

my Mod: Extended RPG [W.I.P]

Link to comment
Share on other sites

  • 2 weeks later...

please help me

 

also, i want to add something like a suprise box

i want to let it drop some items randomly, i only can let it drop 1 thing

i want that it will drop items with degrees

 

like 45% dirt, 25% cobble stone 20% sand    5% iron ingot    2% coal  2% gold and 1% diamond

 

i think i must put something in this method

 

public int idDropped(int par1, Random par2Random, int par3)

{

        //but what????????????????

}

 

 

please can someone help me

 

thanks and merry christmas

 

Mark136

my Mod: Extended RPG [W.I.P]

Link to comment
Share on other sites

public int idDropped(int par1, Random par2Random, int par3){

int derp = par2Random.nextInt(99);

if(derp<45){

return this.dirt.blockId;

}else{

if(derp<70){

return this.cobblestone.blockId;

}else{

if(derp<90){

return this.sand.blockId

}else{

if(derp<95){

return iron.itemId;

}else{

if(derp<97){

return item.coal.itemId;

}else{

if(derp<99){

return item.gold.itemId;

}else{

return item.diamond.itemId;

}

}

}

}

}

}

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Link to comment
Share on other sites

I looked in BlockFlower.java and found:

public boolean canPlace(World world, int i, int j, int k) {

    return super.canPlace(world, i, j, k) && this.d_(world.getTypeId(i, j - 1, k));

}

protected boolean d_(int i) {

    return i == Block.GRASS.id || i == Block.DIRT.id || i == Block.SOIL.id;

}

 

I'm not sure if d_ is still called that in forge now, but one of those functions is what you want to override.

 

(I'm at work now and can't access forge. If you need more help, I'll check it when I get home.)

Link to comment
Share on other sites

You were on the right track with the first thing you tried. You just need to add on to your if statement when it checks the ID of the block you are clicking on.

 

You need to make it so that it will check to make sure that they block you are clicking on is your FarmField, and check that it is not Grass or Dirt

 

it would look something like this

 

protected boolean canThisPlantGrowOnThisBlockID(int i)

      {   

          return i == Mod_Mark136.FarmField.blockID i != Block.Dirt && i != Block.Grass;

      }

 

I'm not sure if that is exactly correct, but it will be something like that.

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.



×
×
  • Create New...

Important Information

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