Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
Correctly adjust the harvest levels depending on the tool. (This basi…
Browse files Browse the repository at this point in the history
…cally only affects gravel ores.)
  • Loading branch information
bonii-xx committed Aug 10, 2014
1 parent 15d85fe commit 729617d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
Expand Up @@ -10,6 +10,7 @@
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.oredict.OreDictionary;
import tconstruct.world.blocks.GravelOre;

/**
* Used to modify the harvest levels of all known/findable tools and blocks. Vanilla and modded.
Expand Down Expand Up @@ -92,7 +93,11 @@ private static void modifyBlock(ItemStack stack, int harvestLevel)
Log.debug(String.format("Changed Harvest Level of %s from %d to %d", stack.getUnlocalizedName(), block.getHarvestLevel(stack.getItemDamage()), harvestLevel));
}

block.setHarvestLevel("pickaxe", harvestLevel, stack.getItemDamage());
// gravelore gets shovel level instead of pickaxe.
if(block instanceof GravelOre)
block.setHarvestLevel("shovel", harvestLevel, stack.getItemDamage());
else
block.setHarvestLevel("pickaxe", harvestLevel, stack.getItemDamage());
}

private static void modifyTools()
Expand All @@ -102,31 +107,37 @@ private static void modifyTools()
for(Object o : Item.itemRegistry)
{
Item item = (Item) o;
if(!item.getToolClasses(tmp).contains("pickaxe"))
continue;

// adapt harvest levels
int old = item.getHarvestLevel(tmp, "pickaxe");
// wood/gold tool unchanged
if(old <= 0)
continue;

int hlvl = 0;
switch(old)
{
// stone tool: nerfed to wood level
case 1: hlvl = HarvestLevels._0_stone; break;
// iron tool
case 2: hlvl = HarvestLevels._3_iron; break;
// diamond tool
case 3: hlvl = HarvestLevels._5_diamond; break;
// default... we just increase it?
default: hlvl = old+1;
}
// cycle through all toolclasses. usually this'll either be pickaxe, shovel or axe. But mods could add items with multiple.
for(String toolClass : item.getToolClasses(tmp)) {
// adapt harvest levels
int old = item.getHarvestLevel(tmp, toolClass);
// wood/gold tool unchanged
if (old <= 0)
continue;

int hlvl = 0;
switch (old) {
// stone tool: nerfed to wood level
case 1:
hlvl = HarvestLevels._0_stone;
break;
// iron tool
case 2:
hlvl = HarvestLevels._3_iron;
break;
// diamond tool
case 3:
hlvl = HarvestLevels._5_diamond;
break;
// default... we just increase it?
default:
hlvl = old + 1;
}

item.setHarvestLevel("pickaxe", hlvl);
if(Config.logMiningLevelChanges)
Log.debug(String.format("Changed Harvest Level of %s from %d to %d", item.getUnlocalizedName(), old, hlvl));
item.setHarvestLevel(toolClass, hlvl);
if (Config.logMiningLevelChanges)
Log.debug(String.format("Changed Harvest Level for %s of %s from %d to %d", toolClass, item.getUnlocalizedName(), old, hlvl));
}
}

if(Config.logMiningLevelChanges)
Expand Down
Expand Up @@ -18,15 +18,7 @@
/**
* The Harvest-Tweaks Pulse. If this were a separate mod instead of pulse-module, it'd be a @Mod
* This pulse modifies the harvest level of all tools and blocks.
*
* A short overview:
* 0. Wood/Stone
* 1. Flint/Copper
* 2. Iron
* 3. Obsidian
* 4. Ardite
* 5. Cobalt
* 6. Manyullym
* Check util.HarvestLevels for more info.
*
* Check the oreDictlevels to get an idea of what can be harvested with each tier.
*/
Expand Down

0 comments on commit 729617d

Please sign in to comment.