Attempt to implement the Living Armour upgrade for the Grim Reaper's Sprint.

This commit is contained in:
WayofTime 2016-02-09 20:22:14 -05:00
parent 9add936ddf
commit 2be1d50541
4 changed files with 98 additions and 8 deletions

View file

@ -31,6 +31,17 @@ public class LivingArmour implements ILivingArmour
public int maxUpgradePoints = 100;
public int totalUpgradePoints = 0;
public StatTracker getTracker(String key)
{
if (trackerMap.containsKey(key))
{
return trackerMap.get(key);
} else
{
return null;
}
}
@Override
public Multimap<String, AttributeModifier> getAttributeModifiers()
{
@ -86,7 +97,7 @@ public class LivingArmour implements ILivingArmour
@Override
public void notifyPlayerOfUpgrade(EntityPlayer user, LivingArmourUpgrade upgrade)
{
ChatUtil.sendChat(user, TextHelper.localize(chatBase + "newUpgrade"));
ChatUtil.sendChat(user, TextHelper.localizeEffect(chatBase + "newUpgrade"));
}
/**

View file

@ -1,8 +1,27 @@
package WayofTime.bloodmagic.registry;
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
import WayofTime.bloodmagic.livingArmour.upgrade.*;
import WayofTime.bloodmagic.livingArmour.tracker.*;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerFood;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMovement;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPoison;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeHealthboost;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeKnockbackResist;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeMeleeDamage;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePhysicalProtect;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePoisonResist;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSpeed;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist;
public class ModArmourTrackers
{
@ -17,6 +36,7 @@ public class ModArmourTrackers
LivingArmourHandler.registerStatTracker(StatTrackerHealthboost.class);
LivingArmourHandler.registerStatTracker(StatTrackerMeleeDamage.class);
LivingArmourHandler.registerStatTracker(StatTrackerArrowShot.class);
LivingArmourHandler.registerStatTracker(StatTrackerGrimReaperSprint.class);
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeSpeed(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeDigging(0));
@ -27,5 +47,7 @@ public class ModArmourTrackers
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeHealthboost(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeMeleeDamage(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeArrowShot(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeStepAssist(0));
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeGrimReaperSprint(0));
}
}

View file

@ -21,6 +21,7 @@ import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.LivingHealEvent;
@ -33,8 +34,8 @@ import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.Event.Result;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import WayofTime.bloodmagic.ConfigHandler;
import WayofTime.bloodmagic.api.BloodMagicAPI;
@ -58,13 +59,16 @@ import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
import WayofTime.bloodmagic.livingArmour.LivingArmour;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerArrowShot;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerDigging;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerGrimReaperSprint;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerHealthboost;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerMeleeDamage;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerPhysicalProtect;
import WayofTime.bloodmagic.livingArmour.tracker.StatTrackerSelfSacrifice;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeArrowShot;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeDigging;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeGrimReaperSprint;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeSelfSacrifice;
import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradeStepAssist;
import WayofTime.bloodmagic.registry.ModBlocks;
import WayofTime.bloodmagic.registry.ModItems;
import WayofTime.bloodmagic.registry.ModPotions;
@ -78,18 +82,68 @@ public class EventHandler
{
Random random = new Random();
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityDeath(LivingDeathEvent event)
{
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null)
{
StatTrackerGrimReaperSprint.incrementCounter(armour);
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.grimReaper", chestStack);
if (upgrade instanceof LivingArmourUpgradeGrimReaperSprint && ((LivingArmourUpgradeGrimReaperSprint) upgrade).canSavePlayer(player))
{
((LivingArmourUpgradeGrimReaperSprint) upgrade).applyEffectOnRebirth(player);
event.setCanceled(true);
event.setResult(Result.DENY);
}
armour.writeDirtyToNBT(ItemLivingArmour.getArmourTag(chestStack));
}
}
}
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityUpdate(LivingEvent.LivingUpdateEvent event)
{
if (event.entityLiving instanceof EntityPlayer)
{
EntityPlayer entityPlayer = (EntityPlayer) event.entityLiving;
EntityPlayer player = (EntityPlayer) event.entityLiving;
if (event.entityLiving.isPotionActive(ModPotions.boost))
{
entityPlayer.stepHeight = 1.0f;
player.stepHeight = 1.0f;
} else
{
entityPlayer.stepHeight = 0.5f;
boolean hasAssist = false;
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.stepAssist", chestStack);
if (upgrade instanceof LivingArmourUpgradeStepAssist)
{
player.stepHeight = ((LivingArmourUpgradeStepAssist) upgrade).getStepAssist();
hasAssist = true;
}
}
}
if (!hasAssist)
{
player.stepHeight = 0.5f;
}
}
}
}

View file

@ -280,6 +280,8 @@ tooltip.BloodMagic.livingArmour.upgrade.physicalProtect=Tough Skin
tooltip.BloodMagic.livingArmour.upgrade.health=Healthy
tooltip.BloodMagic.livingArmour.upgrade.meleeDamage=Fierce Strike
tooltip.BloodMagic.livingArmour.upgrade.arrowShot=Trick Shot
tooltip.BloodMagic.livingArmour.upgrade.stepAssist=Step Assist
tooltip.BloodMagic.livingArmour.upgrade.grimReaper=Grim Reaper's Sprint
tooltip.BloodMagic.livingArmour.upgrade.level=%s (Level %d)
tooltip.BloodMagic.livingArmour.hasGoggles=&oContains Goggles of Revealing
@ -331,7 +333,8 @@ chat.BloodMagic.ritual.activate=A rush of energy flows through the ritual!
chat.BloodMagic.ritual.notValid=You feel that these runes are not configured correctly...
chat.BloodMagic.livingArmour.upgrade.poisonRemove=You are starting to feel better already!
chat.BloodMagic.livingArmour.newUpgrade=Upgrade acquired!
chat.BloodMagic.livingArmour.upgrade.grimReaper=&6A shadowy force pulls you from the brink of death!
chat.BloodMagic.livingArmour.newUpgrade=&4Upgrade acquired!
# JustEnoughItems
jei.BloodMagic.recipe.altar=Blood Altar