This repository has been archived by the owner on Mar 10, 2021. It is now read-only.
forked from iguanaman/IguanaTweaksTConstruct
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Diamond/Emeralds can now be added to bronze level tools to increase t…
…heir mining level to diamond
- Loading branch information
Showing
5 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...in/java/iguanaman/iguanatweakstconstruct/harvestlevels/modifiers/ModBonusMiningLevel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters