Added "Trick Shot" upgrade to the armour - when trained, your bow will shoot more than one arrow.
This commit is contained in:
parent
2cf7da8603
commit
828edf298e
|
@ -4,6 +4,7 @@ Version 2.0.0-4
|
|||
- Added Physical resistance upgrade (Tough skin)
|
||||
- Added health boost upgrade (Healthy)
|
||||
- Added melee damage upgrade (Fierce strike)
|
||||
- Added trick shot upgrade (Have fun finding it! :D)
|
||||
- Added T5 orb recipe and Demonic Activation Crystal
|
||||
|
||||
------------------------------------------------------
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package WayofTime.bloodmagic.livingArmour;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.ILivingArmour;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
|
||||
public class LivingArmourUpgradeArrowShot extends LivingArmourUpgrade
|
||||
{
|
||||
public static final int[] costs = new int[] { 20, 50, 90, 160, 290 };
|
||||
public static final int[] extraArrow = new int[] { 1, 2, 3, 4, 5 };
|
||||
|
||||
public LivingArmourUpgradeArrowShot(int level)
|
||||
{
|
||||
super(level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return Constants.Mod.MODID + ".upgrade.arrowShot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxTier()
|
||||
{
|
||||
return 5; // Set to here until I can add more upgrades to it.
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCostOfUpgrade()
|
||||
{
|
||||
return costs[this.level];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUnlocalizedName()
|
||||
{
|
||||
return tooltipBase + "arrowShot";
|
||||
}
|
||||
|
||||
public int getExtraArrows()
|
||||
{
|
||||
return extraArrow[this.level];
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package WayofTime.bloodmagic.livingArmour;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.Constants;
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade;
|
||||
import WayofTime.bloodmagic.api.livingArmour.StatTracker;
|
||||
|
||||
public class StatTrackerArrowShot extends StatTracker
|
||||
{
|
||||
public int totalShots = 0;
|
||||
|
||||
public static HashMap<LivingArmour, Integer> changeMap = new HashMap<LivingArmour, Integer>();
|
||||
public static int[] shotsRequired = new int[] { 50, 200, 700, 1500, 3000 };
|
||||
|
||||
public static void incrementCounter(LivingArmour armour)
|
||||
{
|
||||
changeMap.put(armour, changeMap.containsKey(armour) ? changeMap.get(armour) + 1 : 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUniqueIdentifier()
|
||||
{
|
||||
return Constants.Mod.MODID + ".tracker.trickShot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resetTracker()
|
||||
{
|
||||
this.totalShots = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag)
|
||||
{
|
||||
totalShots = tag.getInteger(Constants.Mod.MODID + ".tracker.trickShot");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag)
|
||||
{
|
||||
tag.setInteger(Constants.Mod.MODID + ".tracker.trickShot", totalShots);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour)
|
||||
{
|
||||
if (changeMap.containsKey(livingArmour))
|
||||
{
|
||||
int change = Math.abs(changeMap.get(livingArmour));
|
||||
if (change > 0)
|
||||
{
|
||||
totalShots += Math.abs(changeMap.get(livingArmour));
|
||||
|
||||
changeMap.put(livingArmour, 0);
|
||||
|
||||
this.markDirty();
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LivingArmourUpgrade> getUpgrades()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if (totalShots >= shotsRequired[i])
|
||||
{
|
||||
upgradeList.add(new LivingArmourUpgradeArrowShot(i));
|
||||
}
|
||||
}
|
||||
|
||||
return upgradeList;
|
||||
}
|
||||
}
|
|
@ -56,7 +56,7 @@ public class StatTrackerMovement extends StatTracker
|
|||
return false;
|
||||
}
|
||||
|
||||
if (player.isAirBorne)
|
||||
if (!player.onGround)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package WayofTime.bloodmagic.registry;
|
||||
|
||||
import WayofTime.bloodmagic.api.livingArmour.LivingArmourHandler;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeArrowShot;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeHealthboost;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeKnockbackResist;
|
||||
|
@ -39,5 +40,6 @@ public class ModArmourTrackers
|
|||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradePhysicalProtect(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeHealthboost(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeMeleeDamage(0));
|
||||
LivingArmourHandler.registerArmourUpgrade(new LivingArmourUpgradeArrowShot(0));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
package WayofTime.bloodmagic.util.handler;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.event.entity.player.PlayerEvent;
|
||||
import net.minecraftforge.event.world.BlockEvent;
|
||||
|
@ -29,8 +36,10 @@ import WayofTime.bloodmagic.item.ItemAltarMaker;
|
|||
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
|
||||
import WayofTime.bloodmagic.item.gear.ItemPackSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmour;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeArrowShot;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.LivingArmourUpgradeSelfSacrifice;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerArrowShot;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerDigging;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerHealthboost;
|
||||
import WayofTime.bloodmagic.livingArmour.StatTrackerMeleeDamage;
|
||||
|
@ -44,6 +53,8 @@ import WayofTime.bloodmagic.util.helper.TextHelper;
|
|||
|
||||
public class EventHandler
|
||||
{
|
||||
Random random = new Random();
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityDeath(LivingHurtEvent event)
|
||||
{
|
||||
|
@ -279,4 +290,93 @@ public class EventHandler
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onArrowFire(ArrowLooseEvent event)
|
||||
{
|
||||
World world = event.entityPlayer.worldObj;
|
||||
ItemStack stack = event.bow;
|
||||
EntityPlayer player = event.entityPlayer;
|
||||
|
||||
boolean hasFullSet = true;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
ItemStack armourStack = player.getCurrentArmor(i);
|
||||
if (armourStack == null || !(armourStack.getItem() instanceof ItemLivingArmour))
|
||||
{
|
||||
hasFullSet = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasFullSet)
|
||||
{
|
||||
ItemStack chestStack = player.getCurrentArmor(2);
|
||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||
if (armour != null)
|
||||
{
|
||||
StatTrackerArrowShot.incrementCounter(armour);
|
||||
|
||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.arrowShot", chestStack);
|
||||
if (upgrade instanceof LivingArmourUpgradeArrowShot)
|
||||
{
|
||||
int i = event.charge;
|
||||
float f = (float) i / 20.0F;
|
||||
f = (f * f + f * 2.0F) / 3.0F;
|
||||
|
||||
if ((double) f < 0.1D)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (f > 1.0F)
|
||||
{
|
||||
f = 1.0F;
|
||||
}
|
||||
|
||||
int numberExtra = ((LivingArmourUpgradeArrowShot) upgrade).getExtraArrows();
|
||||
for (int n = 0; n < numberExtra; n++)
|
||||
{
|
||||
EntityArrow entityarrow = new EntityArrow(world, player, f * 2.0F);
|
||||
|
||||
double velocityModifier = 0.6 * f;
|
||||
entityarrow.motionX += (random.nextDouble() - 0.5) * velocityModifier;
|
||||
entityarrow.motionY += (random.nextDouble() - 0.5) * velocityModifier;
|
||||
entityarrow.motionZ += (random.nextDouble() - 0.5) * velocityModifier;
|
||||
|
||||
if (f == 1.0F)
|
||||
{
|
||||
entityarrow.setIsCritical(true);
|
||||
}
|
||||
|
||||
int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);
|
||||
|
||||
if (j > 0)
|
||||
{
|
||||
entityarrow.setDamage(entityarrow.getDamage() + (double) j * 0.5D + 0.5D);
|
||||
}
|
||||
|
||||
int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);
|
||||
|
||||
if (k > 0)
|
||||
{
|
||||
entityarrow.setKnockbackStrength(k);
|
||||
}
|
||||
|
||||
if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
|
||||
{
|
||||
entityarrow.setFire(100);
|
||||
}
|
||||
|
||||
entityarrow.canBePickedUp = 2;
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
world.spawnEntityInWorld(entityarrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -226,6 +226,7 @@ tooltip.BloodMagic.livingArmour.upgrade.knockback=Body Builder
|
|||
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.level=(Level %d)
|
||||
|
||||
# Ritual
|
||||
|
|
Loading…
Reference in a new issue