• 0

    posted a message on Creative Icons Taking from Others.

    Also because you mentioned the difference I took a look at my block class for my planks.

    Under the Block class I have a getSubBlocks method and in my itemBlock class for my planks I have subTypes set to true and it still works fine without extending ItemBlockWithMetadata.
    Are these completely unnecessary lines of code to have in my planks classes? Or at the least should it be set to false? I am just a little bit confused at how this metadata for damage values affects the grab of textures.

    Posted in: Modification Development
  • 0

    posted a message on Creative Icons Taking from Others.
    Quote from coolAlias»

    If your block has subtypes, your ItemBlock needs to also have subtypes and be able to differentiate between damage (i.e. metadata) values, otherwise it treats every damage value as the same block.


    Look at the ItemBlockWithMetadata class and you'll see exactly what is needed to make an ItemBlock work with metadata, but you shouldn't need to code your own when you can just extend ItemBlockWithMetadata instead.


    Okay this gives me a good amount of information to explore with but one more question;

    I have noticed, like you referenced, that some mods have created their own ItemBlockWithMetadata (specifically Highlands is one I've noticed it with as I have been picking apart how they generate their world type). What purpose would require a custom tailored one for a mod that adds biome gen and environmental blocks? I might understand the use for it if you have several "machine" blocks or structures that use a very unique metadata but why Highlands? And should I invest my time earlier than later in learning this for my environmental mod?


    Posted in: Modification Development
  • 0

    posted a message on Creative Icons Taking from Others.
    Quote from coolAlias»

    Extended ItemBlockWithMetadata instead of ItemBlock.


    Genius! Thank you so much!

    I am attempting to really learn here from this and the way my code is constructed so would you be able to explain why I need to extend classes like this from ItemBlockWithMetadata when my itemblockplanks class only needs to extend from ItemBlock?

    Posted in: Modification Development
  • 0

    posted a message on Creative Icons Taking from Others.

    Okay, so I apologize for being so uneducated about this stuff but do you mind helping me just a bit further?

    So I slapped this in my ItemBlockNWDyeFlowers;

    public void setTexture(String string) {
    for (int i = 0; i < flowers.length; i++) {
    setTexture("Reference.MOD_ID:" + flowersi);
    }
    }

    this look right for a setTexture method?

    Now when I try to add any variation of .getTexture(blah blah blah) under my initialization a ton of stuff goes wack in a lot of different ways. Some examples include it wanting me to delete my .setBlockName under initialization and then spirals from there to creativing varios methods in my block class to get it to work only to crash on start up. Another issue that comes up is the .getTexture wanting to bounce between ".getTexture", ".setTexture", ".setBlockTexture", and ".getBlockTexture".

    So when I am attempting to point to my set texture in my ItemBlock class stuff goes crazy. Any idea what I might be doing wrong?

    Posted in: Modification Development
  • 0

    posted a message on Creative Icons Taking from Others.

    Okay I will try this and let you know if it works in a bit. I have some morning plans.
    I will also let you know if this works in my saplings class.

    Do you have any way to explain to me why I have to do this for my flowers and not my blocks?

    I appreciate you staying dedicated to grinding a solution out with me XD I am fairly new and understanding vanilla code and how it interacts is by far the hardest for me.

    Posted in: Modification Development
  • 0

    posted a message on Creative Icons Taking from Others.

    (Edit): Yes my item Block is supposed to pull the same texture relative to the flower but it doesn't.

    My equation is the same in both classes (block and itemblock).


    Each flower has a different texture and when I place them everything works dandy and fine. It is only in the creative tab that my other flowers steal the icon from the Canna icon. The equation is all the same and it works perfectly in my block class for planks with no issue, same equation there. That is why I am so confused why something is going wrong in the creative tabs with my flower icons.

    Posted in: Modification Development
  • 0

    posted a message on Creative Icons Taking from Others.
    Quote from Sytheren»

    for (int i = 0; i < flowers.length; i++) {</p> <p>texture = iconRegister.registerIcon(Reference.MOD_ID + ":" + flowers + "Flower");</p> <p>}


    I think that's the problem. So you're applying the exact texture for all the variants of the block? If that's what you want, then I'll have another look.


    And what is your problem exactly?


    Weird, when you wrote it above it isn't texturei =iconRegister but that is what it should be and what it is in my mod. And now that I look every time I paste the i's don't show so here is the issue.

    My exact problem is that when I load up my Canna texture (named CannaFlower because the equation pulls for the item name in the string then in the registration of the icon also pulls for Flower to be added) the texture for my Canna also applies to my testFlower BUT only in creative tabs. When I place the TestFlower Block it registers the correct icon. How do I fix it stealing my canna texture in creativetabs?

    The equation (with the i's included this time):

    texture = new IIcon[flowers.length];

    for (int i = 0; i < flowers.length; i++) {
    texturei = iconRegister.registerIcon(Reference.MOD_ID + ":" + flowersi + "Flower");



    The int texture equals the length of my flowers which is a string declared at the top listing the names of my flowers for the class.
    The int i (declaring new int here) equals 0 (putting it at "Canna" because minecraft registers starting at 0) then states that if "i" is less than my total flowers string length add one to the integer bringing it up to one in this case.
    Next I am stating that texture (which both were just declared) equals the registration of my Icons taking the name for the png file.
    "(Reference.MOD_ID + ":" + flowersi + "Flower")" Reference points to my info, flowersi should be taking the correct order of Canna then Test, and then Flower added on the end just for my mental and organizational purposes for naming in my lang file.


    I hope now that this is explained correctly with the 's included it should show I am not just being dumb with my equation >.< because you would be correct with just "flowers" it would only take the first in the string for all.


    EDIT: Every time i put i in brackets it gets really messed up and I have no clue why. Sorry, just pretend there is one after texture = and one after flowers when it pulls for registericon

    Posted in: Modification Development
  • 0

    posted a message on Rendering custom flowers in flower pots

    From what I have dug into this is impossible without huge base edits to vanilla code. There is supposedly a one mod that has done this and integrates modded plants into the flower pot. Maybe take a look at that and making your mod compatible with it.

    Posted in: Modification Development
  • 0

    posted a message on How to add new Flowers

    Hey there, not sure how you are trying to generate these things but from my limited knowledge the easiest way to get any plants and trees to generate is by making your own biomes. With that the only way anyone has seemed to get biomes with their things to properly generate is by making a new world type (like the "Default" or "Superflat" world types you see under advanced world creation options.

    As far as getting ores to spawn throughout the world, this is fairly simple from what I know, have read, and have seen.

    Here are some video links that may help you delve into biomes and tree/plant generation. Dig through them to find how to make melons, I am certain without doubts I watched a video on this through one of these extensive tutorials. The easiest way for melons is just making your own quick block-class for them and generating them in your biomes.

    This series specifically helped me set up my own worldType and biome generation for it. Shows you how to get the world type to generate everything vanilla does normally while adding in your own custom biomes. Adding custom biomes that mostly play on items already in minecraft are quite easy with this setup.

    https://www.youtube.com/playlist?list=PLQutSmhiLfZlxpv2R7JYCv0Ad63cXD0Nv


    These tutorials mostly helped me understand some basic yet very important organization for a mod. Also walks though blocks, armor and tools/weapons pretty heavily.

    https://www.youtube.com/user/wuppygaming/videos

    https://www.youtube.com/playlist?list=PLBB_qIzJkK4t7F9MMK-HO9CIpbtSyCYP0

    https://www.youtube.com/playlist?list=PL6lD77ZPqAf3iKjm4sjSX9pauDiwPPE7L


    This is a heavy series that covers a ton! I believe your ore generation is within this one. If not google "Ore Generation Mods" and/or add "Custom" to that.
    https://www.youtube.com/user/nealegaming/playlists


    If you can't find the melons anywhere let me know and I will dig through my history (it was very recent I saw this). They are a bit more complicated because they require a stem that grows the melon in a different block, so this requires ticking checks for spaces around it. Not hard if you find a good tutorial but complicated if you know nothing.

    Like I said. Let me know if you need anything more. I will do my best. I am a beginner as well but I know a bit more than you it sounds like so I am glad to help someone in a similar position.

    Posted in: Modification Development
  • 0

    posted a message on Creative Icons Taking from Others.

    So I have two different classes that have stumbled into the same issue. Both my saplings and my flowers block classes are only applying the first texture in my string to all related Block Icons only in my creative tab.

    Here is more of a specific walk-through of the issue relating to one class, my flowers class;
    Under my creative tab all flowers register the Icon of my first flower (Canna Flower). This seems to happen ONLY in my creative tabs as when I place the other flowers they either have no texture (if I haven't slapped it in yet) or the normal texture it should. It only duplicates the texture icon in my inventory tabs. Same thing happens with my saplings. I have spent a decent amount of time in days trying to figure this one out. I have looked at other open source mods to see how they do things with their flowers but none that I have looked at use the same string equation that lets me simplify how I name and add more blocks to my classes.


    I ran into this issue when making some BlockLog classes but the issue was that the extended BlockLog Class only supports four Log types. I figured this may be the issue at first but in both my Flower and Sapling Class I shrunk how many blocks were made down to two for testing purposes till I solved this issue. Still happens so I believe that is not the issue anymore because it appears the vanilla code supports up to 16 (0 through 15) flower blocks per class.


    I hope someone can help me >.< I imagine it is something simple that I just have not learned yet.

    Here is my BlockFlower class;


    package com.naturalworld.objects;

    import java.util.List;

    import net.minecraft.block.BlockBush;
    import net.minecraft.block.material.Material;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.IIcon;

    import com.naturalworld.lib.Reference;

    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;

    public class BlockNWDyeFlowers extends BlockBush{

    @SideOnly(Side.CLIENT)
    private IIcon[] texture;

    final static String[] flowers = new String[] {"Canna", "test"};

    protected BlockNWDyeFlowers(){
    super(Material.plants);
    this.setStepSound(soundTypeGrass);
    this.setCreativeTab(BlocksandItems.naturalworldTab);
    }

    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item block, CreativeTabs creativeTabs, List list) {
    for (int i = 0; i < flowers.length; i++) {
    list.add(new ItemStack(block, 1, i));
    }
    }

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconRegister) {
    texture = new IIcon[flowers.length];

    for (int i = 0; i < flowers.length; i++) {
    texture = iconRegister.registerIcon(Reference.MOD_ID + ":" + flowers + "Flower");
    }
    }

    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int meta) {
    return texture[meta];
    }

    public int damageDropped(int meta) {
    return meta;
    }
    }


    Here is my ItemBlockFlower class;


    package com.naturalworld.itemblocks;

    import net.minecraft.block.Block;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.item.ItemStack;

    public class ItemBlockNWDyeFlowers extends ItemBlock{

    final static String[] flowers = new String[] {"Canna", "test"};

    public ItemBlockNWDyeFlowers(Block block) {
    super(block);
    this.setHasSubtypes(true);
    }

    public String getUnlocalizedName(ItemStack itemstack) {
    int i = itemstack.getItemDamage();
    if (i < 0 || i >= flowers.length) {
    i = 0;
    }

    return super.getUnlocalizedName() + "." + flowers + "Flower";
    }

    public int getMetadata(int meta) {
    return meta;
    }
    }


    And here is where I declare, initialize, and register all my blocks and items;


    package com.naturalworld.objects;

    import com.naturalworld.itemblocks.ItemBlockNWDyeFlowers;

    import net.minecraft.block.Block;
    import net.minecraft.block.BlockFlower;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.Item;
    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;

    public class BlocksandItems {

    // Can put "public static ToolMaterial..." here
    // Can put "public static ArmorMaterial..." here

    public static void mainRegistry(){
    initializeObjects();
    registerObjects();
    }

    // Declare all Creative Tabs here

    public static CreativeTabs naturalworldTab = new CreativeTabs("The Natural World") {
    @SideOnly(Side.CLIENT)
    public Item getTabIconItem() {
    return Item.getItemFromBlock(Blocks.sapling);
    }
    };

    // Declare all blocks and items here

    public static Block dyeFlowers;

    // Initialize all blocks and items here

    public static void initializeObjects(){
    dyeFlowers = new BlockNWDyeFlowers().setBlockName("blockDyeFlower");
    }

    // Register all blocks and items here

    public static void registerObjects(){
    GameRegistry.registerBlock(dyeFlowers, ItemBlockNWDyeFlowers.class, dyeFlowers.getUnlocalizedName());

    }
    }

    Posted in: Modification Development
  • 0

    posted a message on Customizing Block Bounds for Crops?
    Quote from Choonster»

    Override Block#getRenderType to return 1. This is the render type used by flowers and tall grass and renders the block's icon in a cross pattern.


    Ahhhhh thank you so much! So simple, I feel stupid XD


    I have noticed that even though I know a bit of java most of what is preventing me from moving forward faster than I am is learning the vanilla code and how to interact with it. Would you happen to have a solid recommendation or direction you could point me for me to really start learning how to play off from minecraft's code?

    Posted in: Modification Development
  • 0

    posted a message on Customizing Block Bounds for Crops?
    Quote from wakkytabbakky»


    @Override
    public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)
    {
    this.setBlockBounds(0, 0, 0, 2, 2, 1);
    super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);
    }


    @Override
    public void setBlockBoundsForItemRender()
    {
    this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1F, 1.0F);
    }

    add this in to the code and it should give you custom collisionboxes / block bounds. block bounds at bottom is the lines you see around the item and the top part is the actual collision box that you cant walk through


    Thanks so much! I will play around with this and see if it will suit my needs.

    Since you could help me here, on a very similar topic I am curious if you know how Magical Crops gets their crop textures to take two 2D textures and slice them in the middle for a 3D one, like one of those cut-out-stand figures. I hope I am explaining myself well enough XD

    Posted in: Modification Development
  • 0

    posted a message on Customizing Block Bounds for Crops?

    I am attempting to implement some of my own crops to an Environment Mod I am working on.

    For starts I have only added a Soybean Plant, Seed and Item. They nicely fall under one class;


    package net.environment.mod.blocks;

    import java.util.Random;

    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.environment.mod.Core;
    import net.environment.mod.itemblocks.ItemBlockLogs;
    import net.environment.mod.itemblocks.ItemBlockPlanks;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockCrops;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.init.Blocks;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemFood;
    import net.minecraft.item.ItemSeeds;
    import net.minecraft.util.IIcon;

    public class CropsECO extends BlockCrops {

    public static Item cropSoybeanSeeds;
    public static Item cropSoybeans;
    public static Block cropSoybeanPlant;

    public static void init() {
    registerBlocks();
    }

    public static void registerBlocks() {
    cropSoybeanPlant = new CropsECO().setBlockName("SoybeanPlant");
    GameRegistry.registerBlock(cropSoybeanPlant, "SoybeanPlant");
    cropSoybeanSeeds = new ItemSeeds(cropSoybeanPlant, Blocks.farmland).setUnlocalizedName("SoybeanSeeds").setTextureName(Core.modID + ":SoybeanSeeds").setCreativeTab(Core.tabEnvironment);
    GameRegistry.registerItem(cropSoybeanSeeds, "SoybeanSeeds", Core.modID);
    cropSoybeans = new ItemFood(2, 0.8F, false).setUnlocalizedName("Soybeans").setTextureName(Core.modID + ":Soybeans").setCreativeTab(Core.tabEnvironment);
    GameRegistry.registerItem(cropSoybeans, "Soybeans", Core.modID);
    }

    @SideOnly(Side.CLIENT)
    private IIcon[] iconArray;

    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconRegister) {
    this.iconArray = new IIcon[4];

    for (int i = 0; i < this.iconArray.length; i++) {
    this.iconArray = iconRegister.registerIcon(Core.modID + ":" + this.getUnlocalizedName().substring(5) + (i + 1));
    }
    }

    public IIcon getIcon(int side, int metadata) {
    if (metadata < 7) {
    if (metadata == 6) {
    metadata = 5;
    }

    return this.iconArray[metadata >> 1];
    }

    return this.iconArray[3];
    }

    public int quantityDropped (Random random) {
    return 1;
    }

    protected Item func_149866_i() {
    return CropsECO.cropSoybeanSeeds;
    }

    protected Item func_149865_P() {
    return CropsECO.cropSoybeans;
    }
    }


    I tried adding this just below declaring my Items and Blocks;

    protected CropsECO() {
    float f = 0.5F;
    this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, 0.25F, 0.5F + f);

    }


    I messed around with the values and it didn't seem to do anything but make my plant unable to grow with bonemeal and probably not grow at all as I am assuming what I didn't rendered the crop class void so it didn't act like a crop.

    My question is: Can I make this work with the way my current class is setup or will I have to make my own BlockCrops.class imitating Vanilla's for my custom crop block bounds to take effect on the specific crops I want?

    Posted in: Modification Development
  • 0

    posted a message on 1.7.10 Blocks taking textures from other blocks
    Quote from coolAlias»

    It's because you are extending from BlockLog which extends from BlockRotatedPillar, and in that class the #getIcon method only allows for FOUR variants, yet you have EIGHT.


    BlockRotatedPillar uses the first 2 bits of the metadata (i.e. values 0, 1, 2, and 3) to determine the TYPE of block, e.g. Oak, and the last 2 bits as rotation flags: 0 is up and down (default, no flag), bit 4 for north and south, and bit 8 for east and west.


    Solution: split your wood blocks into more than one block, with a max of 4 types per block.


    Okay I did need to do it with leaves as well.

    Now I am having an issue getting my saplings to generate the tree :/ Mind helping?


    Here is my Sapling Class:


    package net.environment.mod.biome.features;

    import java.util.List;
    import java.util.Random;

    import cpw.mods.fml.common.registry.GameRegistry;
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockSapling;
    import net.environment.mod.itemblocks.ItemBlockSaplings;
    import net.minecraft.client.renderer.texture.IIconRegister;
    import net.minecraft.creativetab.CreativeTabs;
    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.minecraft.world.gen.feature.WorldGenBigTree;
    import net.minecraft.world.gen.feature.WorldGenCanopyTree;
    import net.minecraft.world.gen.feature.WorldGenForest;
    import net.minecraft.world.gen.feature.WorldGenMegaJungle;
    import net.minecraft.world.gen.feature.WorldGenMegaPineTree;
    import net.minecraft.world.gen.feature.WorldGenSavannaTree;
    import net.minecraft.world.gen.feature.WorldGenTaiga2;
    import net.minecraft.world.gen.feature.WorldGenTrees;
    import net.minecraft.world.gen.feature.WorldGenerator;
    import net.environment.mod.Core;
    import net.environment.mod.biome.features.*;

    public class SaplingsECO extends BlockSapling {

    public static Block blockSaplings;

    public static void init() {
    registerBlocks();
    }

    public static void registerBlocks() {
    Block blockSaplings = new SaplingsECO().setBlockName("blockSaplings");
    GameRegistry.registerBlock(blockSaplings, ItemBlockSaplings.class, blockSaplings.getUnlocalizedName().substring(5));
    }

    public static String[] saplings = new String[] {"Chestnut", "Holly"};
    private static IIcon[] iconLength = new IIcon[saplings.length];
    protected SaplingsECO() {
    float f = 0.4F;
    this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
    this.setCreativeTab(Core.tabEnvironment);
    }

    /**
    * Ticks the block if it's been scheduled
    */
    public void updateTick(World world, int x, int y, int z, Random random)
    {
    if (!world.isRemote)
    {
    super.updateTick(world, x, y, z, random);

    if (world.getBlockLightValue(x, y + 1, z) >= 9 && random.nextInt(7) == 0)
    {
    this.func_149879_c(world, x, y, z, random);
    }
    }
    }

    /**
    * Gets the block's texture. Args: side, meta
    */
    @SideOnly(Side.CLIENT)
    public IIcon getIcon(int side, int meta)
    {
    meta &= 7;
    return iconLength[MathHelper.clamp_int(meta, 0, 5)];
    }

    //markOrGrowMarked
    public void func_149879_c(World world, int x, int y, int z, Random random)
    {
    int l = world.getBlockMetadata(x, y, z);

    if ((l & 8) == 0)
    {
    world.setBlockMetadataWithNotify(x, y, z, l | 8, 4);
    }
    else
    {
    this.func_149878_d(world, x, y, z, random);
    }
    }

    //growTree
    public void func_149878_d(World world, int x, int y, int z, Random random) {
    if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(world, random, x, y, z)) return;
    int l = world.getBlockMetadata(x, y, z) & 7;
    Object object = random.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
    int i1 = 0;
    int j1 = 0;
    boolean flag = false;

    switch (l) {
    case 0:
    object = new WorldGenChestnutTree(LogsFruitECO.blockLogsFruit, LeavesFruitECO.blockLeavesFruit, 0, 0, false, 5, 3, false);
    break;
    case 1:
    object = new WorldGenHollyTree(LogsFruitECO.blockLogsFruit, LeavesFruitECO.blockLeavesFruit, 1, 1, false, 4, 3, false);
    break;
    case 2:
    break;
    case 3:
    break;
    case 4:
    break;
    case 5:
    break;
    default:
    break;

    }

    Block block = Blocks.air;

    if (flag)
    {
    world.setBlock(x + i1, y, z + j1, block, 0, 4);
    world.setBlock(x + i1 + 1, y, z + j1, block, 0, 4);
    world.setBlock(x + i1, y, z + j1 + 1, block, 0, 4);
    world.setBlock(x + i1 + 1, y, z + j1 + 1, block, 0, 4);
    }
    else
    {
    world.setBlock(x, y, z, block, 0, 4);
    }

    if (!((WorldGenerator)object).generate(world, random, x + i1, y, z + j1))
    {
    if (flag)
    {
    world.setBlock(x + i1, y, z + j1, this, l, 4);
    world.setBlock(x + i1 + 1, y, z + j1, this, l, 4);
    world.setBlock(x + i1, y, z + j1 + 1, this, l, 4);
    world.setBlock(x + i1 + 1, y, z + j1 + 1, this, l, 4);
    }
    else
    {
    world.setBlock(x, y, z, this, l, 4);
    }
    }
    }
    //isSameSapling
    public boolean func_149880_a(World world, int x, int y, int z, int par1)
    {
    return world.getBlock(x, y, z) == this && (world.getBlockMetadata(x, y, z) & 7) == par1;
    }

    /**
    * Determines the damage on the item the block drops. Used in cloth and wood.
    */
    public int damageDropped(int p_149692_1_)
    {
    return MathHelper.clamp_int(p_149692_1_ & 7, 0, 5);
    }

    /**
    * returns a list of blocks with the same ID, but different meta (eg: wood returns 4 blocks)
    */
    @SideOnly(Side.CLIENT)
    public void registerBlockIcons(IIconRegister iconRegister) {

    for (int i = 0; i < iconLength.length; i++) {
    iconLength = iconRegister.registerIcon(Core.modID + ":" + saplings + "Saplings");
    }
    }

    @SideOnly(Side.CLIENT)
    public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {
    for (int i = 0; i < saplings.length; i++) {
    list.add(new ItemStack(item, 1, i));
    }
    }

    public boolean func_149851_a(World p_149851_1_, int p_149851_2_, int p_149851_3_, int p_149851_4_, boolean p_149851_5_)
    {
    return true;
    }

    public boolean func_149852_a(World p_149852_1_, Random p_149852_2_, int p_149852_3_, int p_149852_4_, int p_149852_5_)
    {
    return (double)p_149852_1_.rand.nextFloat() < 0.45D;
    }

    public void func_149853_b(World p_149853_1_, Random p_149853_2_, int p_149853_3_, int p_149853_4_, int p_149853_5_)
    {
    this.func_149879_c(p_149853_1_, p_149853_3_, p_149853_4_, p_149853_5_, p_149853_2_);
    }

    }


    And here is my WorldGen Class for my Holly Tree (My chestnut class is identical with the appropriate changes):


    package net.environment.mod.biome.features;

    import java.util.Random;

    import net.minecraft.block.Block;
    import net.minecraft.block.BlockSapling;
    import net.minecraft.init.Blocks;
    import net.minecraft.util.Direction;
    import net.minecraft.world.World;
    import net.minecraft.world.gen.feature.WorldGenAbstractTree;
    import net.minecraftforge.common.util.ForgeDirection;

    public class WorldGenHollyTree extends WorldGenAbstractTree
    {
    /** The minimum height of a generated tree. */
    private final int minTreeHeight;
    private final int randomTreeHeight;

    /** True if this tree should grow Vines. */
    private final boolean vinesGrow;

    private final Block wood;
    private final Block leaves;

    /** The metadata value of the wood to use in tree generation. */
    private final int metaWood;
    /** The metadata value of the leaves to use in tree generation. */
    private final int metaLeaves;

    public WorldGenHollyTree(Block wood, Block leaves, int metaWood, int metaLeaves)
    {
    this(wood, leaves, metaWood, metaLeaves, false, 4, 3, false);
    }

    public WorldGenHollyTree(Block wood, Block leaves, int metaWood, int metaLeaves, boolean doBlockNotify, int minTreeHeight, int randomTreeHeight, boolean vinesGrow)
    {
    super(doBlockNotify);

    this.wood = wood;
    this.leaves = leaves;

    this.minTreeHeight = minTreeHeight;
    this.randomTreeHeight = randomTreeHeight;

    this.metaWood = metaWood;
    this.metaLeaves = metaLeaves;
    this.vinesGrow = vinesGrow;
    }

    public boolean generate(World p_76484_1_, Random p_76484_2_, int p_76484_3_, int p_76484_4_, int p_76484_5_)
    {
    int l = p_76484_2_.nextInt(3) + this.minTreeHeight;
    boolean flag = true;

    if (p_76484_4_ >= 1 && p_76484_4_ + l + 1 <= 256)
    {
    byte b0;
    int k1;
    Block block;

    for (int i1 = p_76484_4_; i1 <= p_76484_4_ + 1 + l; ++i1)
    {
    b0 = 1;

    if (i1 == p_76484_4_)
    {
    b0 = 0;
    }

    if (i1 >= p_76484_4_ + 1 + l - 2)
    {
    b0 = 2;
    }

    for (int j1 = p_76484_3_ - b0; j1 <= p_76484_3_ + b0 && flag; ++j1)
    {
    for (k1 = p_76484_5_ - b0; k1 <= p_76484_5_ + b0 && flag; ++k1)
    {
    if (i1 >= 0 && i1 < 256)
    {
    block = p_76484_1_.getBlock(j1, i1, k1);

    if (!this.isReplaceable(p_76484_1_, j1, i1, k1))
    {
    flag = false;
    }
    }
    else
    {
    flag = false;
    }
    }
    }
    }

    if (!flag)
    {
    return false;
    }
    else
    {
    Block block2 = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ - 1, p_76484_5_);

    boolean isSoil = block2.canSustainPlant(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, ForgeDirection.UP, (BlockSapling)SaplingsECO.blockSaplings);
    if (isSoil && p_76484_4_ < 256 - l - 1)
    {
    block2.onPlantGrow(p_76484_1_, p_76484_3_, p_76484_4_ - 1, p_76484_5_, p_76484_3_, p_76484_4_, p_76484_5_);
    b0 = 3;
    byte b1 = 0;
    int l1;
    int i2;
    int j2;
    int i3;

    for (k1 = p_76484_4_ - b0 + l; k1 <= p_76484_4_ + l; ++k1)
    {
    i3 = k1 - (p_76484_4_ + l);
    l1 = b1 + 1 - i3 / 2;

    for (i2 = p_76484_3_ - l1; i2 <= p_76484_3_ + l1; ++i2)
    {
    j2 = i2 - p_76484_3_;

    for (int k2 = p_76484_5_ - l1; k2 <= p_76484_5_ + l1; ++k2)
    {
    int l2 = k2 - p_76484_5_;

    if (Math.abs(j2) != l1 || Math.abs(l2) != l1 || p_76484_2_.nextInt(2) != 0 && i3 != 0)
    {
    Block block1 = p_76484_1_.getBlock(i2, k1, k2);

    if (block1.isAir(p_76484_1_, i2, k1, k2) || block1.isLeaves(p_76484_1_, i2, k1, k2))
    {
    this.setBlockAndNotifyAdequately(p_76484_1_, i2, k1, k2, LeavesFruitECO.blockLeavesFruit, this.metaLeaves);
    }
    }
    }
    }
    }

    for (k1 = 0; k1 < l; ++k1)
    {
    block = p_76484_1_.getBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_);

    if (block.isAir(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_) || block.isLeaves(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_))
    {
    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_, LogsFruitECO.blockLogsFruit, this.metaWood);

    if (this.vinesGrow && k1 > 0)
    {
    if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_ - 1, p_76484_4_ + k1, p_76484_5_))
    {
    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ - 1, p_76484_4_ + k1, p_76484_5_, Blocks.vine, 8);
    }

    if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_ + 1, p_76484_4_ + k1, p_76484_5_))
    {
    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ + 1, p_76484_4_ + k1, p_76484_5_, Blocks.vine, 2);
    }

    if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_ - 1))
    {
    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_ - 1, Blocks.vine, 1);
    }

    if (p_76484_2_.nextInt(3) > 0 && p_76484_1_.isAirBlock(p_76484_3_, p_76484_4_ + k1, p_76484_5_ + 1))
    {
    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_, p_76484_4_ + k1, p_76484_5_ + 1, Blocks.vine, 4);
    }
    }
    }
    }

    if (this.vinesGrow)
    {
    for (k1 = p_76484_4_ - 3 + l; k1 <= p_76484_4_ + l; ++k1)
    {
    i3 = k1 - (p_76484_4_ + l);
    l1 = 2 - i3 / 2;

    for (i2 = p_76484_3_ - l1; i2 <= p_76484_3_ + l1; ++i2)
    {
    for (j2 = p_76484_5_ - l1; j2 <= p_76484_5_ + l1; ++j2)
    {
    if (p_76484_1_.getBlock(i2, k1, j2).isLeaves(p_76484_1_, i2, k1, j2))
    {
    if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2 - 1, k1, j2).isAir(p_76484_1_, i2 - 1, k1, j2))
    {
    this.growVines(p_76484_1_, i2 - 1, k1, j2, 8);
    }

    if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2 + 1, k1, j2).isAir(p_76484_1_, i2 + 1, k1, j2))
    {
    this.growVines(p_76484_1_, i2 + 1, k1, j2, 2);
    }

    if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2, k1, j2 - 1).isAir(p_76484_1_, i2, k1, j2 - 1))
    {
    this.growVines(p_76484_1_, i2, k1, j2 - 1, 1);
    }

    if (p_76484_2_.nextInt(4) == 0 && p_76484_1_.getBlock(i2, k1, j2 + 1).isAir(p_76484_1_, i2, k1, j2 + 1))
    {
    this.growVines(p_76484_1_, i2, k1, j2 + 1, 4);
    }
    }
    }
    }
    }

    if (p_76484_2_.nextInt(5) == 0 && l > 5)
    {
    for (k1 = 0; k1 < 2; ++k1)
    {
    for (i3 = 0; i3 < 4; ++i3)
    {
    if (p_76484_2_.nextInt(4 - k1) == 0)
    {
    l1 = p_76484_2_.nextInt(3);
    this.setBlockAndNotifyAdequately(p_76484_1_, p_76484_3_ + Direction.offsetX[Direction.rotateOpposite[i3]], p_76484_4_ + l - 5 + k1, p_76484_5_ + Direction.offsetZ[Direction.rotateOpposite[i3]], Blocks.cocoa, l1 << 2 | i3);
    }
    }
    }
    }
    }

    return true;
    }
    else
    {
    return false;
    }
    }
    }
    else
    {
    return false;
    }
    }

    /**
    * Grows vines downward from the given block for a given length. Args: World, x, starty, z, vine-length
    */
    private void growVines(World p_76529_1_, int p_76529_2_, int p_76529_3_, int p_76529_4_, int p_76529_5_)
    {
    this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_);
    int i1 = 4;

    while (true)
    {
    --p_76529_3_;

    if (!p_76529_1_.getBlock(p_76529_2_, p_76529_3_, p_76529_4_).isAir(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_) || i1 <= 0)
    {
    return;
    }

    this.setBlockAndNotifyAdequately(p_76529_1_, p_76529_2_, p_76529_3_, p_76529_4_, Blocks.vine, p_76529_5_);
    --i1;
    }
    }
    }


    Hope you can help, I feel so close.

    Posted in: Modification Development
  • 0

    posted a message on 1.7.10 Blocks taking textures from other blocks

    Hey sorry I had one more question, will my leaf and sapling classes need to be split up as well?

    Posted in: Modification Development
  • To post a comment, please or register a new account.