Advertisement
Guest User

mod_cutter

a guest
Jul 23rd, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 10.12 KB | None | 0 0
  1. package net.minecraft.src;
  2.  
  3. import net.minecraft.src.forge.*;
  4.  
  5. import java.util.*;
  6.  
  7. public class mod_cutter extends BaseMod{
  8.  
  9.     public CraftingManager craftingManager = CraftingManager.getInstance();
  10.     public CraftingManagerKnife craftingManagerKnife = CraftingManagerKnife.getInstance();
  11.    
  12.     public static final EnumToolMaterial KRYPTONIUM = EnumHelper.addToolMaterial("KRYPTONIUM", 3, 1561, 8.0F, 3, 10);
  13.     public static final EnumToolMaterial FLINT = EnumHelper.addToolMaterial("FLINT", 3, 100, 4.0F, 2, 5);
  14.    
  15.     public static final Block oak = (new BlockOak(250, 0)).setHardness(2.0F).setBlockName("logOak").setRequiresSelfNotify();
  16.     public static final Block oakLeaves = (new BlockOakLeaves(251, 3)).setHardness(0.2F).setLightOpacity(1).setStepSound(Block.soundGrassFootstep).setBlockName("oakLeaves").setRequiresSelfNotify();
  17.     public static final Block storageTank = (new BlockStorageTank(252,4).setHardness(2.0F).setBlockName("storageTank").setRequiresSelfNotify());
  18.     public static final Block melterIdle = (new BlockMelter(253, false)).setHardness(3.5F).setStepSound(Block.soundStoneFootstep).setBlockName("melter").setRequiresSelfNotify();
  19.     public static final Block melterActive = (new BlockFurnace(254, true)).setHardness(3.5F).setStepSound(Block.soundStoneFootstep).setLightValue(0.875F).setBlockName("melter").setRequiresSelfNotify();
  20.    
  21.     public static final Item kryptoniumPickaxe = (new ItemKryptoniumPickaxe(1001,KRYPTONIUM)).setIconCoord(0,0).setItemName("kryptoniumPickaxe");
  22.     public static final Item bucketWoodEmpty = (new ItemBucketWood(1002,0)).setIconCoord(1,0).setItemName("bucketWood");
  23.     public static final Item bucketWoodWater = (new ItemBucketWood(1003, Block.waterMoving.blockID)).setIconCoord(2, 0).setItemName("bucketWoodWater").setContainerItem(bucketWoodEmpty);
  24.     public static final Item flintKnife = (new ItemKnifeFlint(1004)).setIconCoord(3,0).setItemName("flintKnife");
  25.     public static final Block fluidBed = (new BlockFluidBed(255, 80, Material.wood)).setHardness(2.0F).setBlockName("fluidBed").setRequiresSelfNotify();
  26.    
  27.     public static int storageTankRenderID;
  28.     public static int fluidBedRenderID;
  29.    
  30.     @Override
  31.     public void load() {
  32.         MinecraftForgeClient.preloadTexture("/cutter/Blocks.png");
  33.         MinecraftForgeClient.preloadTexture("/cutter/Gems.png");
  34.         MinecraftForgeClient.preloadTexture("/cutter/Items.png");
  35.         MinecraftForgeClient.preloadTexture("/cutter/Machines.png");
  36.        
  37.         registerBlocks();
  38.        
  39.         //remove recipes MUST go before add recipes
  40.         removeRecipes();
  41.         addRecipes();
  42.        
  43.         storageTankRenderID = ModLoader.getUniqueBlockModelID(this, false);
  44.         fluidBedRenderID = ModLoader.getUniqueBlockModelID(this, false);
  45.        
  46.     }
  47.  
  48.     public void generateSurface(World world, Random rand, int chunkX, int chunkZ){
  49.        
  50.         BiomeGenBase biome = world.getBiomeGenForCoords(chunkX, chunkZ);
  51.         WorldGenOak tree = new WorldGenOak(false);
  52.         if (biome instanceof BiomeGenForest||biome instanceof BiomeGenPlains||biome instanceof BiomeGenTaiga||biome instanceof BiomeGenHills||
  53.                 biome instanceof BiomeGenJungle||biome instanceof BiomeGenSwamp||biome instanceof BiomeGenSnow){
  54.            
  55.             for(int l = 0; l < 5; l++){
  56.                    
  57.                    int i1 = chunkX + rand.nextInt(16);
  58.                    int k1 = chunkZ + rand.nextInt(16);
  59.                    int j1 = world.getHeightValue(k1, i1);
  60.                    tree.generate(world, rand, i1, j1, k1);
  61.                    
  62.                }
  63.            
  64.         }
  65.        
  66.        /*for(int l = 0; l < 100; l++){
  67.            
  68.            int i1 = chunkX + rand.nextInt(16);
  69.            int j1 = rand.nextInt(80);
  70.            int k1 = chunkZ + rand.nextInt(16);
  71.            (new WorldGenMinable(oak.blockID, 10)).generate(world, rand, i1, j1, k1);
  72.            
  73.        }
  74.        */  
  75.    }
  76.    
  77.     public void registerBlocks(){
  78.        
  79.         ModLoader.registerBlock(oak);
  80.         ModLoader.addName(oak, "BlockOak");
  81.        
  82.         ModLoader.registerBlock(storageTank, net.minecraft.src.ItemBlockStorageTank.class);
  83.         ModLoader.addName(new ItemStack(storageTank, 252, 0), "BlockStorageTank0");
  84.         ModLoader.addName(new ItemStack(storageTank, 252, 1), "BlockStorageTank1");
  85.         ModLoader.addName(new ItemStack(storageTank, 252, 2), "BlockStorageTank2");
  86.         ModLoader.addName(new ItemStack(storageTank, 252, 3), "BlockStorageTank3");
  87.         ModLoader.addName(new ItemStack(storageTank, 252, 4), "BlockStorageTank4");
  88.        
  89.         ModLoader.registerBlock(melterIdle);
  90.         ModLoader.addName(melterIdle, "melterIdle");
  91.         ModLoader.registerBlock(melterActive);
  92.         ModLoader.addName(melterActive, "melterActive");
  93.         ModLoader.registerTileEntity(net.minecraft.src.TileEntityMelter.class, "melter");
  94.        
  95.         ModLoader.registerBlock(fluidBed);
  96.         ModLoader.addName(fluidBed, "fluidBed");
  97.        
  98.         ModLoader.addName(kryptoniumPickaxe, "kryptoniumPickaxe");
  99.         ModLoader.addName(bucketWoodEmpty, "bucketWoodEmpty");
  100.         ModLoader.addName(bucketWoodWater, "bucketWoodWater");
  101.         ModLoader.addName(flintKnife, "flintKnife");
  102.     }
  103.    
  104.     public boolean renderWorldBlock(RenderBlocks renderBlocks, IBlockAccess blockAccess, int x, int y, int z, Block block, int l){
  105.        
  106.         if (l == storageTankRenderID){
  107.            
  108.                 return renderStorageTank(block, x, y, z, renderBlocks);
  109.         }else if(l == fluidBedRenderID){
  110.            
  111.                 return renderFluidBed(block, x, y, z, renderBlocks);
  112.                
  113.         }
  114.        
  115.         return false;
  116.    
  117.     }
  118.    
  119.     public boolean renderStorageTank(Block block, int x, int y, int z, RenderBlocks renderBlocks){
  120.        
  121.         Tessellator tes = Tessellator.instance;
  122.         tes.setBrightness(block.getMixedBrightnessForBlock(renderBlocks.blockAccess, x, y, z));
  123.        
  124.         int metaData = renderBlocks.blockAccess.getBlockMetadata(x, y, z);
  125.         short texture = 11;
  126.         switch(metaData){
  127.        
  128.             default:
  129.                 break;
  130.            
  131.             case 1:
  132.                 renderBlocks.renderTopFace(block, (double)x, (double)y - 0.75F, (double)z, texture);
  133.                 break;
  134.  
  135.             case 2:
  136.                 renderBlocks.renderTopFace(block, (double)x, (double)y - 0.5F, (double)z, texture);
  137.                 break;
  138.  
  139.             case 3:
  140.                 renderBlocks.renderTopFace(block, (double)x, (double)y - 0.25F, (double)z, texture);
  141.                 break;
  142.                
  143.         }
  144.        
  145.         block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
  146.         renderBlocks.renderStandardBlock(block, x, y, z);
  147.        
  148.         return true;
  149.        
  150.     }
  151.    
  152.     public boolean renderFluidBed(Block block, int x, int y, int z, RenderBlocks renderBlocks){
  153.        
  154.         int metaData = renderBlocks.blockAccess.getBlockMetadata(x, y, z);
  155.         short topTexture = (short)block.getBlockTextureFromSide(1);
  156.         short sideTexture = (short)block.getBlockTextureFromSide(2);
  157.         short bottomTexture = 80;
  158.        
  159.         block.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
  160.        
  161.         renderBlocks.renderStandardBlock(block, x, y, z);
  162.        
  163.         //renders custom polygons to the block
  164.         renderBlocks.renderTopFace(block, (double)x, (double)y, (double)z, topTexture);
  165.         renderBlocks.renderSouthFace(block, (double)x-0.875F, (double)y, (double)z, sideTexture);
  166.         renderBlocks.renderSouthFace(block, (double)x-0.4375F, (double)y, (double)z, sideTexture);
  167.         renderBlocks.renderNorthFace(block, (double)x+0.875F, (double)y, (double)z, sideTexture);
  168.         renderBlocks.renderNorthFace(block, (double)x+0.4375F, (double)y, (double)z, sideTexture);
  169.         renderBlocks.renderEastFace(block, (double)x, (double)y, (double)z+0.875F, sideTexture);
  170.         renderBlocks.renderWestFace(block, (double)x, (double)y, (double)z-0.875F, sideTexture);
  171.         renderBlocks.renderTopFace(block, (double)x, (double)y-0.1875F, (double)z, bottomTexture);
  172.         renderBlocks.renderBottomFace(block, (double)x, (double)y, (double)z, bottomTexture);
  173.        
  174.        
  175.        
  176.         /*switch(metaData){
  177.        
  178.             default:
  179.                 break;
  180.            
  181.             case 1:
  182.                 renderBlocks.renderTopFace(block, (double)x, (double)y - 0.75F, (double)z, texture);
  183.                 break;
  184.  
  185.             case 2:
  186.                 renderBlocks.renderTopFace(block, (double)x, (double)y - 0.5F, (double)z, texture);
  187.                 break;
  188.  
  189.             case 3:
  190.                 renderBlocks.renderTopFace(block, (double)x, (double)y - 0.25F, (double)z, texture);
  191.                 break;
  192.                
  193.         }*/
  194.        
  195.         return true;
  196.        
  197.     }
  198.    
  199.     public void addRecipes(){
  200.        
  201.         craftingManager.addRecipe(new ItemStack(storageTank, 1), new Object[] {"XX", Character.valueOf('X'), Block.dirt});
  202.         craftingManager.addRecipe(new ItemStack(melterIdle, 1), new Object[] {"X", Character.valueOf('X'), Block.sand});
  203.         craftingManager.addRecipe(new ItemStack(flintKnife, 1), new Object[] {" X", "# ", '#', Item.stick, 'X', Item.flint});
  204.         craftingManager.addRecipe(new ItemStack(Block.stoneOvenIdle), new Object[] {"###", "# #", "###", '#', Block.stone});
  205.         craftingManager.addRecipe(new ItemStack(flintKnife, 1), new Object[] {"#",  '#', Item.stick});
  206.        
  207.         craftingManagerKnife.addRecipe(new ItemStack(bucketWoodEmpty, 1), new Object[] {"# #", " # ", '#', Block.planks});
  208.         craftingManagerKnife.addRecipe(new ItemStack(fluidBed, 1), new Object[] {" # ", "###"," # ", '#', Block.planks});
  209.        
  210.     }
  211.    
  212.     public void removeRecipes(){
  213.        
  214.         List craftingList = CraftingManager.getInstance().getRecipeList();
  215.        
  216.         removeRecipe(Block.stoneOvenIdle, craftingList);
  217.        
  218.     }
  219.    
  220.     public void removeRecipe(Block block, List list){
  221.        
  222.         for(int i = 0; i<list.size();i++){
  223.             Object tmp = list.get(i);
  224.             if(tmp instanceof ShapedRecipes){
  225.                 ShapedRecipes a = (ShapedRecipes)tmp;
  226.                 if((a.getRecipeOutput().itemID==block.blockID) && (a.getRecipeOutput().getItem() instanceof ItemBlock)){
  227.                     System.out.println("removed "+a.getRecipeOutput().getItem().getItemName()+" at "+i+" ShapedRecipe list");
  228.                     list.remove(i);
  229.                    
  230.                 }
  231.             }          
  232.         }
  233.     }
  234.    
  235.     public void removeRecipe(Item item, List list){
  236.        
  237.         for(int i = 0; i<list.size();i++){
  238.             Object tmp = list.get(i);
  239.             if(tmp instanceof ShapedRecipes){
  240.                 ShapedRecipes a = (ShapedRecipes)tmp;
  241.                 if((a.getRecipeOutput().itemID==item.shiftedIndex) && !(a.getRecipeOutput().getItem() instanceof ItemBlock)){
  242.                     System.out.println("removed "+a.getRecipeOutput().getItem().getItemName()+" at "+i+" ShapedRecipe list");
  243.                     list.remove(i);
  244.                    
  245.                 }
  246.             }          
  247.         }
  248.     }
  249.    
  250.     @Override
  251.     public String getVersion() {
  252.         return "1.2.5";
  253.     }
  254.    
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement