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

Commit

Permalink
Add a small chance to obtain stonebound on tools or jagged on weapons…
Browse files Browse the repository at this point in the history
…. :3
  • Loading branch information
bonii-xx committed Aug 13, 2014
1 parent ded5599 commit 9e1aa38
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
@@ -1,5 +1,6 @@
package iguanaman.iguanatweakstconstruct.leveling;

import iguanaman.iguanatweakstconstruct.leveling.modifiers.ModShoddy;
import iguanaman.iguanatweakstconstruct.reference.Config;
import iguanaman.iguanatweakstconstruct.util.Log;
import net.minecraft.entity.player.EntityPlayer;
Expand Down Expand Up @@ -115,6 +116,7 @@ else if(tool.getItem() instanceof BowBase)
}
}

;
if(choice == null)
return null;

Expand Down Expand Up @@ -191,6 +193,9 @@ private static boolean applyModifier(Modifier modifier, EntityPlayer player, Ite
case BEHEADING: return addBeheadingModifier(player, tool);
case LIFESTEAL: return addLifeStealModifier(player, tool);
case KNOCKBACK: return addKnockbackModifier(player, tool);
// special modifier
case JAGGED: return addJaggedModifier(player, tool);
case STONEBOUND:return addStoneboundModifier(player, tool);
}

return false;
Expand Down Expand Up @@ -297,6 +302,19 @@ public static boolean addKnockbackModifier(EntityPlayer player, ItemStack tool)
}


/* Special Enchantments */
public static boolean addJaggedModifier(EntityPlayer player, ItemStack tool)
{
return addGenericModifier(player, tool, ModShoddy.ModJagged.key, "message.levelup.jagged", EnumChatFormatting.RED.toString());
}

public static boolean addStoneboundModifier(EntityPlayer player, ItemStack tool)
{
return addGenericModifier(player, tool, ModShoddy.ModStonebound.key, "message.levelup.stonebound", EnumChatFormatting.AQUA.toString());
}



/* Backbone ;o */

// simple call
Expand Down Expand Up @@ -349,6 +367,10 @@ private static ItemModifier getModifier(String key)
return TinkerTools.modAttack;
}

if(key.equals(ModShoddy.ModJagged.key))
return ModShoddy.ModJagged;
if(key.equals(ModShoddy.ModStonebound.key))
return ModShoddy.ModStonebound;

for(ItemModifier modifier : ModifyBuilder.instance.itemModifiers)
if(modifier.key.equals(key)) {
Expand Down Expand Up @@ -416,6 +438,7 @@ private static int getToolModifierWeight(Modifier mod)
case EMERALD: return 35;
case REPAIR: return 50;
case REINFORCED:return 88;
case STONEBOUND:return 5;
}

// less useful bonuses
Expand Down Expand Up @@ -450,6 +473,7 @@ private static int getWeaponModifierWeight(Modifier mod)
case BEHEADING: return 50;
case LIFESTEAL: return 30;
case KNOCKBACK: return 50;
case JAGGED: return 5;
}

if(Config.randomBonusesAreUseful)
Expand Down Expand Up @@ -527,7 +551,10 @@ public enum Modifier {
BANE,
BEHEADING,
LIFESTEAL,
KNOCKBACK;
KNOCKBACK,
// Special modifiers
STONEBOUND,
JAGGED;

// !!! DO NOT CHANGE THESE !!!
// They're used for NBTTags and Configs. Changing them would break compatibility
Expand Down
@@ -0,0 +1,51 @@
package iguanaman.iguanatweakstconstruct.leveling.modifiers;

import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StatCollector;
import tconstruct.modifiers.tools.ModBoolean;

// Shoddy handles Stonebound and Jagged. Jagged simply is negative Stonebound.
public class ModShoddy extends ModBoolean {
public static ModShoddy ModJagged = new ModShoddy("BonusJagged", EnumChatFormatting.RED.toString(), StatCollector.translateToLocal("materialtraits.jagged"), -0.5f);
public static ModShoddy ModStonebound = new ModShoddy("BonusStonebound", EnumChatFormatting.AQUA.toString(), StatCollector.translateToLocal("materialtraits.stonebound"), 0.5f);

protected float change;

public ModShoddy(String tag, String c, String tip, float change) {
super(new ItemStack[0], 0, tag, c, tip);

this.change = change;
}

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

// cannot apply jagged if we have stonebound
if(tags.getFloat("Shoddy") > 0.0f && this.key.equals(ModJagged.key))
return false;

// cannot apply stonebound if jagged
if(tags.getFloat("Shoddy") < 0.0f && this.key.equals(ModStonebound.key))
return false;

return true;
}


@Override
public void modify(ItemStack[] input, ItemStack tool) {
super.modify(input, tool);

// go make stonebound/jagged...y
NBTTagCompound tags = tool.getTagCompound().getCompoundTag("InfiTool");
tags.setFloat("Shoddy", tags.getFloat("Shoddy") + change);
}

// no visual effect :(
@Override
public void addMatchingEffect(ItemStack input) {
}
}

0 comments on commit 9e1aa38

Please sign in to comment.