Skip to content

Commit

Permalink
Dying costs 10% max durability of tools
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Oct 7, 2014
1 parent 85a9bb2 commit d39db6d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/tconstruct/tools/TinkerToolEvents.java
Expand Up @@ -5,6 +5,7 @@
import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent;
import java.util.List;
import net.minecraft.entity.*;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
Expand All @@ -13,6 +14,7 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.*;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.oredict.*;
import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
import tconstruct.TConstruct;
Expand Down Expand Up @@ -432,4 +434,23 @@ else if (evt.Name.equals("crystalCertusQuartz"))
TinkerTools.modAttack.addStackToMatchList(evt.Ore, 24);
}
}


@SubscribeEvent
public void damageToolsOnDeath (PlayerDropsEvent event)
{
for(EntityItem drop : event.drops)
{
// we're only interested in tools
if(!(drop.getEntityItem().getItem() instanceof ToolCore) || !drop.getEntityItem().hasTagCompound())
continue;

// damage tools by 10% of their total durability!
NBTTagCompound tags = drop.getEntityItem().getTagCompound().getCompoundTag("InfiTool");
int dur = tags.getInteger("TotalDurability");
dur /= 10;

AbilityHelper.damageTool(drop.getEntityItem(), dur, event.entityPlayer, true);
}
}
}

2 comments on commit d39db6d

@TherminatorX
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q: Will tools break or be destroyed if </10% at time of death? Or does something really funky go on?

@fuj1n
Copy link
Member

@fuj1n fuj1n commented on d39db6d Oct 8, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some Diablo logic?

Please sign in to comment.