Spawning plant

Started by Zergmazter on Tue, 07/31/2018 - 23:46

Topic category: Help with modding (Java Edition)

Last seen on 02:07, 12. Mar 2020
Joined Nov 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Spawning plant
Tue, 07/31/2018 - 23:46

This is for Mcreator 1.7.3. I added the 0.001 value on (int i = 0; i < 0.001; i++).

I'm trying to modify my plant so that it doesn't spawn in clusters like ores. Can someone help me understand how this works? I've tried modifying the values but I don't think I understand how to decrease the size of the clusters. While I have decreased the amount spawned, I have not decreased the cluster size. Sometimes up to 15 plants spawn in a single cluster.

Code:

    public void generateSurface(World world, java.util.Random randomGenerator, int chunkX, int chunkZ) {
        for (int i = 0; i < 0.001; i++) {
            int l6 = chunkX + randomGenerator.nextInt(16) + 8;
            int i11 = randomGenerator.nextInt(128);
            int l14 = chunkZ + randomGenerator.nextInt(16) + 8;
            (new WorldGenFlowers(mcreator_beetRootPlant.block)).generate(world, randomGenerator, l6, i11, l14);
        }
    }

Do you need some of the other code? It seemed unrelated, but I could be wrong.

Last seen on 02:07, 12. Mar 2020
Joined Nov 2014
User points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • Tracker tickets:
  • MCreator plugins:
  • Comments:
Just in case: package mod…
Tue, 07/31/2018 - 23:50

Just in case:

package mod.mcreator;

import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.common.EnumPlantType;

import net.minecraft.world.gen.feature.WorldGenFlowers;
import net.minecraft.world.World;
import net.minecraft.world.IBlockAccess;
import net.minecraft.util.IIcon;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.block.BlockReed;
import net.minecraft.block.Block;

import java.util.Random;

import cpw.mods.fml.relauncher.SideOnly;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

public class mcreator_beetRootPlant {

    public mcreator_beetRootPlant() {
    }

    public static Block block;

    public Object instance;

    public void generateNether(World world, Random random, int chunkX, int chunkZ) {
    }

    public int addFuel(ItemStack fuel) {
        return 0;
    }

    public void serverLoad(FMLServerStartingEvent event) {
    }

    public void preInit(FMLPreInitializationEvent event) {

        GameRegistry.registerBlock(block, "BeetRootPlant");
    }

    public void registerRenderers() {
    }

    public void load() {
    }

    static {

        block = (Block) (new BlockCustomFlower()).setHardness(0.01F).setResistance(2.0F).setLightLevel(0.0F).setBlockTextureName("beetroots_stage3")
                .setBlockName("BeetRootPlant").setStepSound(Block.soundTypeGrass);
        Block.blockRegistry.addObject(391, "BeetRootPlant", block);

    }

    public void generateSurface(World world, java.util.Random randomGenerator, int chunkX, int chunkZ) {
        for (int i = 0; i < 0.001; i++) {
            int l6 = chunkX + randomGenerator.nextInt(16) + 8;
            int i11 = randomGenerator.nextInt(128);
            int l14 = chunkZ + randomGenerator.nextInt(16) + 8;
            (new WorldGenFlowers(mcreator_beetRootPlant.block)).generate(world, randomGenerator, l6, i11, l14);
        }
    }

    public static class BlockCustomFlower extends BlockReed {
        IIcon la;

        public BlockCustomFlower() {
            super();
            this.setCreativeTab(CreativeTabs.tabDecorations);
        }

        @SideOnly(Side.CLIENT)
        @Override
        public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
            return this.la;
        }

        @SideOnly(Side.CLIENT)
        @Override
        public void registerBlockIcons(IIconRegister reg) {
            la = reg.registerIcon("beetroots_stage3");
        }

        @Override
        public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) {
            return EnumPlantType.Plains;
        }

        @Override
        public boolean canPlaceBlockAt(World p_149742_1_, int p_149742_2_, int p_149742_3_, int p_149742_4_) {
            Block block = p_149742_1_.getBlock(p_149742_2_, p_149742_3_ - 1, p_149742_4_);
            return (block.canSustainPlant(p_149742_1_, p_149742_2_, p_149742_3_ - 1, p_149742_4_, ForgeDirection.UP, this) || block == mcreator_beetRootPlant.block);
        }

        @SideOnly(Side.CLIENT)
        public int colorMultiplier(IBlockAccess p_149720_1_, int p_149720_2_, int p_149720_3_, int p_149720_4_) {
            return 16777215;
        }

        public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_) {
            if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_) == block
                    || this.func_150170_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_)) {
                if (p_149674_1_.isAirBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_)) {
                    int l;
                    for (l = 1; p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - l, p_149674_4_) == this; ++l) {
                        ;
                    }
                    if (l < 1) {
                        int i1 = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
                        if (i1 == 15) {
                            p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, this);
                            p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 0, 4);
                        } else {
                            p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, i1 + 1, 4);
                        }
                    }
                }
            }
        }

        @SideOnly(Side.CLIENT)
        public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_) {
            return mcreator_beetRoot.block;
        }

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

        public Item getItemDropped(int par1, Random par2Random, int par3) {
            return mcreator_beetRoot.block;
        }
    }
}