Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MOD_FILE CONTENTS:
- package net.minecraft.src;
- import java.util.Random;
- public class mod_tutorial extends BaseMod
- {
- //Textures
- //Blocks
- public static final Block SoulFlower = (BlockSoulFlowers)(new BlockSoulFlowers(211, ModLoader.addOverride("/terrain.png","/Blocks/soulflower.png"))).setHardness(0.0F).setStepSound(Block.soundGrassFootstep).setBlockName("SoulFlower");
- //Tree Blocks
- //Very Complex Blocks
- //Items
- public void load()
- {
- //Registering
- ModLoader.registerBlock(SoulFlower);
- //Adding names
- ModLoader.addName(SoulFlower, "Soul Flower");
- //Tile Entity
- //Biomes
- ModLoader.addBiome(BiomeGenBase.souldesert);
- //Crafting Recipes
- //Smelting Recipes
- //Shapeless Recipes
- }
- public String getVersion()
- {
- return "1.2.5";
- }
- }
- BLOCKSOULFLOWERS FILE:
- package net.minecraft.src;
- import java.util.Random;
- public class BlockSoulFlowers extends Block
- {
- protected BlockSoulFlowers(int par1, int par2, Material par3Material)
- {
- super(par1, par3Material);
- blockIndexInTexture = par2;
- setTickRandomly(true);
- float f = 0.2F;
- setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3F, 0.5F + f);
- }
- protected BlockSoulFlowers(int par1, int par2)
- {
- this(par1, par2, Material.plants);
- }
- /**
- * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
- */
- public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
- {
- return super.canPlaceBlockAt(par1World, par2, par3, par4) && canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
- }
- /**
- * Gets passed in the blockID of the block below and supposed to return true if its allowed to grow on the type of
- * blockID passed in. Args: blockID
- */
- protected boolean canThisPlantGrowOnThisBlockID(int par1)
- {
- return par1 == Block.slowSand.blockID;
- }
- /**
- * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
- * their own) Args: x, y, z, neighbor blockID
- */
- /**
- * Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
- */
- public boolean canBlockStay(World par1World, int par2, int par3, int par4)
- {
- return (par1World.getFullBlockLightValue(par2, par3, par4) >= 8 || par1World.canBlockSeeTheSky(par2, par3, par4)) && canThisPlantGrowOnThisBlockID(par1World.getBlockId(par2, par3 - 1, par4));
- }
- /**
- * Returns a bounding box from the pool of bounding boxes (this means this box can change after the pool has been
- * cleared to be reused)
- */
- public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int i)
- {
- return null;
- }
- /**
- * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
- * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
- */
- public boolean isOpaqueCube()
- {
- return false;
- }
- /**
- * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
- */
- public boolean renderAsNormalBlock()
- {
- return false;
- }
- /**
- * The type of render function that is called for this block
- */
- public int getRenderType()
- {
- return 1;
- }
- }
- WORLDGENSOULFLOWERS FILE:
- package net.minecraft.src;
- import java.util.Random;
- public class WorldGenSoulFlowers extends WorldGenerator
- {
- /** The ID of the plant block used in this plant generator. */
- private int plantBlockId;
- public WorldGenSoulFlowers(int par1)
- {
- plantBlockId = par1;
- }
- public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5)
- {
- for (int i = 0; i < 64; i++)
- {
- int j = (par3 + par2Random.nextInt(8)) - par2Random.nextInt(8);
- int k = (par4 + par2Random.nextInt(4)) - par2Random.nextInt(4);
- int l = (par5 + par2Random.nextInt(8)) - par2Random.nextInt(8);
- if (par1World.isAirBlock(j, k, l) && mod_tutorial.SoulFlower.canBlockStay(par1World, j, k, l))
- {
- par1World.setBlock(j, k, l, plantBlockId);
- }
- }
- return true;
- }
- }
- BIOMEDECORATOR STUFF:
- // ADD THIS OUTSIDE OF PUBLIC BIOMEDECORATOR(BiomeGenBasepar1BiomeGenBase)
- protected int soulflowersperchunk;
- protected WorldGenerator soulflowerGen
- // ADD THIS INSIDE OF PUBLIC BIOMEDECORATOR(BiomeGenBasepar1BiomeGenBase)
- soulflowerGen = new WorldGenSoulFlowers(mod_tutorial.SoulFlower.blockID);
- soulflowersperchunk = 0;
- ADD THIS TO THE DECORATE METHOD:
- for(int q = 0; q < soulflowersperchunk; q++)
- {
- int q1 = chunk_X + randomGenerator.nextInt(16) + 8;
- int q2 = randomGenerator.nextInt(128);
- int q3 = chunk_Z + randomGenerator.nextInt(16) + 8;
- soulflowerGen.generate(currentWorld, randomGenerator, q1, q2, q3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement