From 729d6a266fc1425dee54e9d65d647fb6b40c2c93 Mon Sep 17 00:00:00 2001 From: Bernhard Bonigl Date: Wed, 8 Oct 2014 22:26:54 +0200 Subject: [PATCH] Change Death penality to take difficulty into account. Easy/Peaceful = no penality, normal = 5%, hard = 10% --- .../java/tconstruct/tools/TinkerToolEvents.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/tconstruct/tools/TinkerToolEvents.java b/src/main/java/tconstruct/tools/TinkerToolEvents.java index b8f7270f303..7ce49f51f25 100644 --- a/src/main/java/tconstruct/tools/TinkerToolEvents.java +++ b/src/main/java/tconstruct/tools/TinkerToolEvents.java @@ -13,6 +13,7 @@ import net.minecraft.item.*; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.*; +import net.minecraft.world.EnumDifficulty; import net.minecraftforge.event.entity.living.*; import net.minecraftforge.event.entity.player.PlayerDropsEvent; import net.minecraftforge.oredict.*; @@ -436,12 +437,22 @@ else if (evt.Name.equals("crystalCertusQuartz")) } + @SubscribeEvent public void damageToolsOnDeath (PlayerDropsEvent event) { if(!PHConstruct.deathPenality) return; - + + EnumDifficulty difficulty = event.entityPlayer.worldObj.difficultySetting; + // easy and peaceful don't punish + if(difficulty == EnumDifficulty.PEACEFUL || difficulty == EnumDifficulty.EASY) + return; + + int punishment = 20; // normal has 5% + if(difficulty == EnumDifficulty.HARD) + punishment = 10; // hard has 10% + for(EntityItem drop : event.drops) { // we're only interested in tools @@ -451,7 +462,7 @@ public void damageToolsOnDeath (PlayerDropsEvent event) // damage tools by 10% of their total durability! NBTTagCompound tags = drop.getEntityItem().getTagCompound().getCompoundTag("InfiTool"); int dur = tags.getInteger("TotalDurability"); - dur /= 10; + dur /= punishment; AbilityHelper.damageTool(drop.getEntityItem(), dur, event.entityPlayer, true); }