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

Commit

Permalink
Fix emerald/diamond being taken into account incorrectly if the diamo…
Browse files Browse the repository at this point in the history
…nd-required config is off #131
  • Loading branch information
bonii-xx committed Apr 26, 2015
1 parent 73cff2c commit 4c464f8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 13 deletions.
Expand Up @@ -86,8 +86,17 @@ public static boolean toolNeedsUpdating(ItemStack itemStack)
int realHlvl = TConstructRegistry.getMaterial(tags.getInteger("Head")).harvestLevel();

// unboosted but boost requires -> we need to reduce the hlvl by 1
if(Config.pickaxeBoostRequired && !LevelingLogic.isBoosted(tags) && (itemStack.getItem() instanceof Pickaxe || itemStack.getItem() instanceof Hammer))
return hlvl != Math.max(realHlvl-1, 0);
if(Config.pickaxeBoostRequired && !LevelingLogic.isBoosted(tags) && (itemStack.getItem() instanceof Pickaxe || itemStack.getItem() instanceof Hammer)) {
int min = 0;
if(PHConstruct.miningLevelIncrease) {
if(tags.getBoolean("Diamond"))
min = 3;
else if(tags.getBoolean("Emerald"))
min = 2;
}

return hlvl != Math.max(realHlvl - 1, min);
}

// if it's boosted, check if it's boosted by a diamond from bronze level
if(tags.hasKey("GemBoost") && realHlvl == HarvestLevels._4_bronze) {
Expand Down
Expand Up @@ -15,6 +15,7 @@

import java.util.Arrays;

import tconstruct.TConstruct;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.ModifyBuilder;
import tconstruct.library.crafting.ToolBuilder;
Expand Down Expand Up @@ -199,19 +200,26 @@ else if(partMaterialId == 3 && oldMaterialId != 3) {
if(tags.hasKey("GemBoost"))
tags.removeTag("GemBoost");

// if boosted by vanilla diamond modifier, then we have to respect that.
if(!Config.changeDiamondModifier || !IguanaTweaksTConstruct.pulsar.isPulseLoaded(Reference.PULSE_HARVESTTWEAKS))
// vanilla tcon allows harvestlevel change
if(PHConstruct.miningLevelIncrease)
{
// was the tool boosted with a diamond?
if(tags.getBoolean("Diamond") && tags.getInteger("HarvestLevel") < HarvestLevels._6_obsidian) // returns false if tag is not present
tags.setInteger("HarvestLevel", HarvestLevels._6_obsidian);
// ...with an emerald?
if(tags.getBoolean("Emerald") && tags.getInteger("HarvestLevel") < HarvestLevels._5_diamond)
tags.setInteger("HarvestLevel", HarvestLevels._5_diamond);
// if boosted by vanilla diamond modifier, then we have to respect that if vanilla tcon allows harvestlevel change
// check is either modifier-changed OR harvestlevels, because the changeDiamondModifier is basically false if the pulse isn't loaded
if(PHConstruct.miningLevelIncrease && (!Config.changeDiamondModifier || !TConstruct.pulsar.isPulseLoaded(Reference.PULSE_HARVESTTWEAKS)))
{
int min = 0;
if(tags.getBoolean("Diamond")) {
min = 3;
if(TConstruct.pulsar.isPulseLoaded(Reference.PULSE_HARVESTTWEAKS))
min = HarvestLevels._6_obsidian;
}
else if(tags.getBoolean("Emerald")) {
min = 2;
if(TConstruct.pulsar.isPulseLoaded(Reference.PULSE_HARVESTTWEAKS))
min = HarvestLevels._5_diamond;
}

if(tags.getInteger("HarvestLevel") < min)
tags.setInteger("HarvestLevel", min);
}

// handle Leveling/xp (has to be done first before we change the stats so we get the correct old values)
if(LevelingLogic.hasXp(tags))
{
Expand Down

0 comments on commit 4c464f8

Please sign in to comment.