Modified the Dwarven Might skill to better change the mining speed when mining.

This commit is contained in:
WayofTime 2016-10-05 16:06:52 -04:00
parent 16a4857dfb
commit f9b1b91c6d
4 changed files with 39 additions and 4 deletions

View file

@ -6,6 +6,7 @@ Version 2.1.0-66
- Added some more framework for the Living Armour Downgrades.
- Modified the Grim Reaper's Sprint so it is better at later levels.
- Added a Repairing Living Armour Upgrade (trained by damaging the chestplate of the Living Armour while you have a full set on - it repairs all of your armour pieces over time)
- Modified the Dwarven Might skill to better change the mining speed when mining.
------------------------------------------------------
Version 2.1.0-65

View file

@ -78,6 +78,11 @@ public abstract class LivingArmourUpgrade
return HashMultimap.create();
}
public double getMiningSpeedModifier(EntityPlayer player)
{
return 1;
}
public abstract void writeToNBT(NBTTagCompound tag);
public abstract void readFromNBT(NBTTagCompound tag);

View file

@ -17,11 +17,11 @@ public class LivingArmourUpgradeDigging extends LivingArmourUpgrade
public static HashMap<ILivingArmour, Boolean> changeMap = new HashMap<ILivingArmour, Boolean>();
public static final int[] costs = new int[] { 5, 10, 18, 35, 65, 100, 160 };
public static final int[] digHasteTime = new int[] { 20, 40, 60, 100, 100, 100 };
public static final int[] digHasteLevel = new int[] { 0, 0, 1, 1, 2, 2, 2 };
public static final int[] digSpeedTime = new int[] { 0, 60, 60, 100, 100, 100, 100 };
public static final int[] digSpeedLevel = new int[] { 0, 0, 0, 1, 1, 1, 1 };
public static final double[] digSpeedModifier = new double[] { 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.8, 2, 2.2, 2.5 };
public static void hasDug(LivingArmour armour)
{
changeMap.put(armour, true);
@ -32,6 +32,12 @@ public class LivingArmourUpgradeDigging extends LivingArmourUpgrade
super(level);
}
@Override
public double getMiningSpeedModifier(EntityPlayer player)
{
return digSpeedModifier[this.level];
}
@Override
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
{
@ -39,10 +45,9 @@ public class LivingArmourUpgradeDigging extends LivingArmourUpgrade
{
changeMap.put(livingArmour, false);
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, digHasteTime[this.level], digHasteLevel[this.level], false, false));
if (digSpeedTime[this.level] > 0)
{
player.addPotionEffect(new PotionEffect(MobEffects.HASTE, digSpeedTime[this.level], digSpeedLevel[this.level], false, false));
player.addPotionEffect(new PotionEffect(MobEffects.SPEED, digSpeedTime[this.level], digSpeedLevel[this.level], false, false));
}
}
}

View file

@ -15,6 +15,7 @@ import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
@ -40,6 +41,29 @@ import WayofTime.bloodmagic.registry.ModPotions;
@Handler
public class LivingArmourHandler
{
@SubscribeEvent
public void onMiningSpeedCheck(PlayerEvent.BreakSpeed event)
{
EntityPlayer player = event.getEntityPlayer();
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getItemStackFromSlot(EntityEquipmentSlot.CHEST);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
double modifier = 1;
for (LivingArmourUpgrade upgrade : armour.upgradeMap.values())
{
modifier *= upgrade.getMiningSpeedModifier(player);
}
if (modifier != 1)
{
event.setNewSpeed((float) (event.getOriginalSpeed() * modifier));
}
}
}
}
@SubscribeEvent
public void onFinishedItem(LivingEntityUseItemEvent.Finish event)