Package survivalcraft.common

Source Code of survivalcraft.common.GlobalModifications

package survivalcraft.common;

import java.util.logging.Logger;

import net.minecraft.block.Block;
import net.minecraft.block.BlockLeaves;
import net.minecraft.item.Item;
import net.minecraft.item.ItemTool;
import net.minecraft.world.World;

public class GlobalModifications {

  static Logger log = Logger.getLogger("ForgeModLoader");
 
  public static void modifyToolEffectiveness() {

    setAllHarvestLevels();
    hardenExistingBlocks(100F);

  }



  private static void setAllHarvestLevels() {
   
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreIron, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreCoal, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreDiamond, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreEmerald, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreGold, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreLapis, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreRedstone, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockDiamond, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockEmerald, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockGold, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockLapis, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockSteel, "pickaxe", 3);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.stone, "pickaxe", 2);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.cobblestone, "pickaxe", 1);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.glowStone, "pickaxe", 1);
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.netherrack, "pickaxe", 2);
   
    net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.wood, "axe", 2);
    //Material.wood.setIsToolNotRequired(false);
   
    //protected method. The harvest level check is bypassed if the material
    //does not require a specific tool. May need to edit another base class for this.
   
  }

  private static void hardenExistingBlocks(float multiplyHardness) {

    for (Block block : net.minecraft.block.Block.blocksList) {
      if (block != null) {
        float blockHardness = block.getBlockHardness(null, 0, 0, 0);
        blockHardness *= multiplyHardness;
        log.info(String.valueOf(blockHardness));
        log.info(block.toString());
        block.setHardness(blockHardness);
      }
    }
    for (Item item : net.minecraft.item.Item.itemsList) {
      if (item instanceof ItemTool) {
        ItemTool itemTool = (ItemTool) item;
        itemTool.efficiencyOnProperMaterial *= multiplyHardness;
      }
    }
  }

}
TOP

Related Classes of survivalcraft.common.GlobalModifications

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.