drackiseries

Forge Biomes

Nov 13th, 2012
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.12 KB | None | 0 0
  1. MOD_ FILE:
  2.  
  3. package Tutorial;
  4.  
  5. import net.minecraft.src.BiomeGenBase;
  6. import net.minecraft.src.Block;
  7. import net.minecraft.src.CreativeTabs;
  8. import net.minecraft.src.Item;
  9. import net.minecraft.src.ItemStack;
  10. import net.minecraft.src.Material;
  11. import net.minecraftforge.client.MinecraftForgeClient;
  12. import cpw.mods.fml.common.Mod;
  13. import cpw.mods.fml.common.Mod.Init;
  14. import cpw.mods.fml.common.Mod.PreInit;
  15. import cpw.mods.fml.common.event.FMLInitializationEvent;
  16. import cpw.mods.fml.common.event.FMLPreInitializationEvent;
  17. import cpw.mods.fml.common.network.NetworkMod;
  18. import cpw.mods.fml.common.registry.GameRegistry;
  19. import cpw.mods.fml.common.registry.LanguageRegistry;
  20.  
  21. @Mod(modid = "Tutorial", name = "Minecraft Forge Tutorial", version = "v1.0")
  22. @NetworkMod(clientSideRequired = true, serverSideRequired = true)
  23.  
  24. public class mod_tutorial
  25. {
  26.    
  27.     //BLOCKS
  28.    
  29.     public static Block WhiteCyan;
  30.     public static Block DDirt;
  31.     public static DrackiGrass DGrass;
  32.    
  33.     //ITEMS
  34.     public static Item BlueSlimeBall;
  35.    
  36.     //BIOMES
  37.    
  38.     public static BiomeGenBase Dracki;
  39.    
  40.     @PreInit
  41.    
  42.     public void initConfig(FMLPreInitializationEvent fpe)
  43.     {
  44.        
  45.     }
  46.    
  47.     @Init
  48.    
  49.     public void load(FMLInitializationEvent fie)
  50.     {  
  51.         //BLOCKS
  52.         WhiteCyan = (new ModBlock(500,0, Material.cloth).setHardness(0.8F).setStepSound(Block.soundClothFootstep).setBlockName("WhiteCyan").setRequiresSelfNotify());
  53.         DDirt = (new ModBlock(250,5,Material.ground).setHardness(0.5F).setStepSound(Block.soundGravelFootstep).setBlockName("DDirt"));
  54.         DGrass = (DrackiGrass)(new DrackiGrass(251,0)).setHardness(0.6F).setStepSound(Block.soundGrassFootstep).setBlockName("DGrass");
  55.         //ITEMS
  56.        
  57.         BlueSlimeBall = (new ModItem(1000).setItemName("BlueSlimeBall").setCreativeTab(CreativeTabs.tabMisc).setIconCoord(0,0));
  58.        
  59.         //BIOMES
  60.         Dracki = (new BiomeGenDracki(23).setBiomeName("DrackiBiome").setMinMaxHeight(0.0F,0.6F).setEnableSnow());
  61.        
  62.         registeringBlocks();
  63.         blockNames();
  64.         itemNames();
  65.         recipes();
  66.         smelting();
  67.         biomes();
  68.        
  69.         //MINECRAFT FORGE TEXTURE FUNCTIONS
  70.        
  71.         MinecraftForgeClient.preloadTexture("/Texture/modterrain.png");
  72.         MinecraftForgeClient.preloadTexture("/Texture/moditems.png");
  73.        
  74.     }
  75.    
  76.     public void registeringBlocks()
  77.     {
  78.         GameRegistry.registerBlock(WhiteCyan);
  79.         GameRegistry.registerBlock(DDirt);
  80.         GameRegistry.registerBlock(DGrass);
  81.     }
  82.    
  83.     public void blockNames()
  84.     {
  85.         LanguageRegistry.addName(WhiteCyan, "White-Cyan Carpet");
  86.         LanguageRegistry.addName(DDirt,"Dracki Dirt");
  87.         LanguageRegistry.addName(DGrass,"Dracki Grass");
  88.        
  89.     }
  90.    
  91.     public void itemNames()
  92.     {
  93.         LanguageRegistry.addName(BlueSlimeBall, "Blue Slimeball");
  94.     }
  95.    
  96.     public void recipes()
  97.     {
  98.         GameRegistry.addRecipe(new ItemStack(WhiteCyan,1), new Object[] {
  99.             "XY","YX", 'X', new ItemStack(Block.cloth,1,1), 'Y', new ItemStack(Block.cloth,1,9)
  100.         });
  101.        
  102.         GameRegistry.addShapelessRecipe(new ItemStack(BlueSlimeBall,5), new Object[] {
  103.             Item.slimeBall, new ItemStack(Item.dyePowder,1,4)
  104.         });
  105.        
  106.     }
  107.    
  108.     public void smelting()
  109.     {
  110.        
  111.     }
  112.    
  113.     public void biomes()
  114.     {
  115.         GameRegistry.addBiome(Dracki);
  116.     }
  117. }
  118.  
  119. //BIOMEGEN FILE
  120.  
  121. package Tutorial;
  122.  
  123. import java.util.Random;
  124.  
  125. import net.minecraft.src.BiomeGenBase;
  126. import net.minecraft.src.Block;
  127. import net.minecraft.src.World;
  128.  
  129. public class BiomeGenDracki extends BiomeGenBase
  130. {
  131.     public BiomeGenDracki(int par1)
  132.     {
  133.         super(par1);
  134.         this.topBlock = (byte)mod_tutorial.DGrass.blockID;
  135.         this.fillerBlock = (byte)mod_tutorial.DDirt.blockID;
  136.     }
  137.  
  138.     public void decorate(World par1World, Random par2Random, int par3, int par4)
  139.     {
  140.         super.decorate(par1World, par2Random, par3, par4);
  141.     }
  142. }
  143.  
  144.  
  145. //GRASS FILE
  146.  
  147. package Tutorial;
  148.  
  149. import cpw.mods.fml.common.Side;
  150. import cpw.mods.fml.common.asm.SideOnly;
  151. import java.util.Random;
  152.  
  153. import net.minecraft.src.Block;
  154. import net.minecraft.src.ColorizerGrass;
  155. import net.minecraft.src.CreativeTabs;
  156. import net.minecraft.src.IBlockAccess;
  157. import net.minecraft.src.Material;
  158. import net.minecraft.src.World;
  159.  
  160. public class DrackiGrass extends ModBlock
  161. {
  162.     protected DrackiGrass(int par1,int par2)
  163.     {
  164.         super(par1, par2,Material.grass);
  165.         this.blockIndexInTexture = par2;
  166.         this.setTickRandomly(true);
  167.         this.setCreativeTab(CreativeTabs.tabBlock);
  168.     }
  169.  
  170.     /**
  171.      * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata
  172.      */
  173.     public int getBlockTextureFromSideAndMetadata(int par1, int par2)
  174.     {
  175.         return par1 == 1 ? 4 : (par1 == 0 ? mod_tutorial.DDirt.blockIndexInTexture : 3);
  176.     }
  177.  
  178.     @SideOnly(Side.CLIENT)
  179.  
  180.     /**
  181.      * Retrieves the block texture to use based on the display side. Args: iBlockAccess, x, y, z, side
  182.      */
  183.     public int getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
  184.     {
  185.         if (par5 == 1)
  186.         {
  187.             return 4;
  188.         }
  189.         else if (par5 == 0)
  190.         {
  191.             return mod_tutorial.DDirt.blockIndexInTexture;
  192.         }
  193.         else
  194.         {
  195.             return 3;
  196.         }
  197.     }
  198.  
  199.     @SideOnly(Side.CLIENT)
  200.     public int getBlockColor()
  201.     {
  202.         return 0;
  203.     }
  204.  
  205.     @SideOnly(Side.CLIENT)
  206.  
  207.     /**
  208.      * Returns the color this block should be rendered. Used by leaves.
  209.      */
  210.     public int getRenderColor(int par1)
  211.     {
  212.         return this.getBlockColor();
  213.     }
  214.  
  215.     @SideOnly(Side.CLIENT)
  216.  
  217.     /**
  218.      * Returns a integer with hex for 0xrrggbb with this color multiplied against the blocks color. Note only called
  219.      * when first determining what to render.
  220.      */
  221.  
  222.     /**
  223.      * Ticks the block if it's been scheduled
  224.      */
  225.     public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)
  226.     {
  227.         if (!par1World.isRemote)
  228.         {
  229.             if (par1World.getBlockLightValue(par2, par3 + 1, par4) < 4 && par1World.getBlockLightOpacity(par2, par3 + 1, par4) > 2)
  230.             {
  231.                 par1World.setBlockWithNotify(par2, par3, par4, mod_tutorial.DDirt.blockID);
  232.             }
  233.             else if (par1World.getBlockLightValue(par2, par3 + 1, par4) >= 9)
  234.             {
  235.                 for (int var6 = 0; var6 < 4; ++var6)
  236.                 {
  237.                     int var7 = par2 + par5Random.nextInt(3) - 1;
  238.                     int var8 = par3 + par5Random.nextInt(5) - 3;
  239.                     int var9 = par4 + par5Random.nextInt(3) - 1;
  240.                     int var10 = par1World.getBlockId(var7, var8 + 1, var9);
  241.  
  242.                     if (par1World.getBlockId(var7, var8, var9) == mod_tutorial.DDirt.blockID && par1World.getBlockLightValue(var7, var8 + 1, var9) >= 4 && par1World.getBlockLightOpacity(var7, var8 + 1, var9) <= 2)
  243.                     {
  244.                         par1World.setBlockWithNotify(var7, var8, var9, mod_tutorial.DGrass.blockID);
  245.                     }
  246.                 }
  247.             }
  248.         }
  249.     }
  250.  
  251.     /**
  252.      * Returns the ID of the items to drop on destruction.
  253.      */
  254.     public int idDropped(int par1, Random par2Random, int par3)
  255.     {
  256.         return mod_tutorial.DDirt.idDropped(0, par2Random, par3);
  257.     }
  258. }
Advertisement
Add Comment
Please, Sign In to add comment