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

Commit

Permalink
Diamond/Emeralds can now be added to bronze level tools to increase t…
Browse files Browse the repository at this point in the history
…heir mining level to diamond
  • Loading branch information
bonii-xx committed Aug 20, 2014
1 parent f88e4ed commit 4f32d8c
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/assets/iguanatweakstconstruct/lang/en_US.lang
Expand Up @@ -85,6 +85,7 @@ tooltip.level.skill.8=Heroic
tooltip.level.skill.9=Legendary
tooltip.level.skill.10=Godlike
tooltip.level.skill.11=Awesome
tooltip.level.skill.19=MoxieGrrl
tooltip.level.skill.42=boni
tooltip.level.skill.66=Jadedcat
tooltip.level.skill.99=Hacker
Expand Down
1 change: 1 addition & 0 deletions resources/assets/iguanatweakstconstruct/lang/zh_CN.lang
Expand Up @@ -85,6 +85,7 @@ tooltip.level.skill.8=史诗
tooltip.level.skill.9=传奇
tooltip.level.skill.10=神级
tooltip.level.skill.11=出神
tooltip.level.skill.19=MoxieGrrl
tooltip.level.skill.42=boni
tooltip.level.skill.66=Jadedcat
tooltip.level.skill.99=Hacker
Expand Down
Expand Up @@ -3,13 +3,16 @@
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import iguanaman.iguanatweakstconstruct.harvestlevels.modifiers.ModBonusMiningLevel;
import iguanaman.iguanatweakstconstruct.harvestlevels.proxy.HarvestCommonProxy;
import iguanaman.iguanatweakstconstruct.reference.Config;
import iguanaman.iguanatweakstconstruct.reference.Reference;
import iguanaman.iguanatweakstconstruct.restriction.RestrictionHelper;
import iguanaman.iguanatweakstconstruct.util.HarvestLevels;
import iguanaman.iguanatweakstconstruct.util.Log;
import mantle.pulsar.pulse.Handler;
import mantle.pulsar.pulse.Pulse;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
Expand All @@ -19,6 +22,7 @@
import tconstruct.library.tools.ToolMaterial;
import tconstruct.modifiers.tools.ModDurability;
import tconstruct.tools.TinkerTools;
import tconstruct.util.config.PHConstruct;
import tconstruct.world.TinkerWorld;

import java.lang.reflect.Field;
Expand Down Expand Up @@ -52,6 +56,9 @@ public void postInit(FMLPostInitializationEvent event)
HarvestLevelTweaks.modifyHarvestLevels();
MinecraftForge.EVENT_BUS.register(new VanillaToolTipHandler());

if(Config.changeDiamondModifier)
changeDurabilityModifiers();

adaptChestLoot();
}

Expand Down Expand Up @@ -79,4 +86,15 @@ private void adaptChestLoot()
// other stuff should be fine
}
}

private void changeDurabilityModifiers()
{
// deactivate mininglevel increase by tcon
PHConstruct.miningLevelIncrease = false;

Log.info("Adding Diamond/Emerald Modifiers for Mining Levels");
ModifyBuilder.registerModifier(new ModBonusMiningLevel(new ItemStack[] {new ItemStack(Items.diamond) }, "Diamond"));
ModifyBuilder.registerModifier(new ModBonusMiningLevel(new ItemStack[] {new ItemStack(Items.emerald) }, "Emerald"));
}

}
@@ -0,0 +1,59 @@
package iguanaman.iguanatweakstconstruct.harvestlevels.modifiers;

import iguanaman.iguanatweakstconstruct.leveling.LevelingLogic;
import iguanaman.iguanatweakstconstruct.reference.Config;
import iguanaman.iguanatweakstconstruct.util.HarvestLevels;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import tconstruct.library.modifier.ItemModifier;
import tconstruct.modifiers.tools.ModBoolean;
import tconstruct.modifiers.tools.ModDurability;

import java.util.logging.Level;

public class ModBonusMiningLevel extends ItemModifier {
public final String parentTag;

public ModBonusMiningLevel(ItemStack[] recipe, String parentTag) {
super(recipe, 0, "GemBoost");

this.parentTag = parentTag;
}

@Override
protected boolean canModify(ItemStack input, ItemStack[] recipe) {
NBTTagCompound tags = input.getTagCompound().getCompoundTag("InfiTool");

// only on bronze harvest level
if(LevelingLogic.getHarvestLevel(tags) != HarvestLevels._4_bronze)
return false;

// already applied? (actually impossible, but maybe we'll change something in the future
if (tags.getBoolean(key))
return false;

// can be applied without modifier if diamond/emerald modifier is already present
if(tags.getInteger("Modifiers") <= 0 && !tags.getBoolean(parentTag))
return false;

// only if harvestlevel is bronze and can NOT be boosted anymore
return !LevelingLogic.canBoostMiningLevel(tags);
}

@Override
public void modify(ItemStack[] input, ItemStack tool) {
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
// set harvestlevel to diamond
tags.setInteger("HarvestLevel", HarvestLevels._5_diamond);

// no need to remove a modifier, since we either already have a diamond modifier or get it added together with this modifier
// but we have to add the key
tags.setBoolean(key, true);
}

@Override
public void addMatchingEffect(ItemStack input) {
// we don't add an effect, because the diamond/emerald modifier that'll be applied with this will
}
}
Expand Up @@ -40,6 +40,7 @@ public class Config {
public static float xpPerBoostLevelMultiplier;

// Harvest Leveling
public static boolean changeDiamondModifier;
public static int durabilityPercentage;
public static int miningSpeedPercentage;

Expand Down Expand Up @@ -158,6 +159,9 @@ public void sync()
/** HarvestLevel Module **/
configfile.setCategoryComment(CATEGORY_HarvestLevels, "Harvest Level Tweak Module: Introduces a slower mining level progression.");

// changed diamond/emerald modifier
changeDiamondModifier = configfile.getBoolean("diamondRequired", CATEGORY_HarvestLevels, true, "Changes the Diamond and Emerald modifier: Apply it to a bronze level tool to obtain diamond level. Required unless you have steel or similar.");

// Tool durability/speed changes
durabilityPercentage = configfile.getInt("durabilityPercentage", CATEGORY_HarvestLevels, 80, 1, 999, "Change durability of all tool materials (in percent)");
miningSpeedPercentage = configfile.getInt("miningSpeedPercentage", CATEGORY_HarvestLevels, 100, 1, 999, "Change mining speed of all tool materials (in percent)");
Expand Down

0 comments on commit 4f32d8c

Please sign in to comment.