* Added a tag to arrows created through Living Armor's Trickshot Ability. Added a subscribeevent method for the onProjectileImpact event that removes the tag and sets the hurtresistanttime to zero. * Formatted trickshot arrow tags to snake_case
This commit is contained in:
parent
5903cc7e0a
commit
2c49be1bdd
|
@ -29,6 +29,7 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
|
import net.minecraftforge.event.entity.ProjectileImpactEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
import net.minecraftforge.event.entity.living.LivingDeathEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
import net.minecraftforge.event.entity.living.LivingHealEvent;
|
||||||
|
@ -161,10 +162,12 @@ public class LivingArmourHandler
|
||||||
if (event.getItemStack().getItemUseAction() == EnumAction.DRINK)
|
if (event.getItemStack().getItemUseAction() == EnumAction.DRINK)
|
||||||
{
|
{
|
||||||
ItemStack drinkStack = event.getItemStack();
|
ItemStack drinkStack = event.getItemStack();
|
||||||
if(!(drinkStack.getItem() instanceof ItemSplashPotion)) {
|
if (!(drinkStack.getItem() instanceof ItemSplashPotion))
|
||||||
|
{
|
||||||
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.quenched", chestStack);
|
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(BloodMagic.MODID + ".upgrade.quenched", chestStack);
|
||||||
|
|
||||||
if (upgrade instanceof LivingArmourUpgradeQuenched) {
|
if (upgrade instanceof LivingArmourUpgradeQuenched)
|
||||||
|
{
|
||||||
event.setCanceled(true);
|
event.setCanceled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -341,7 +344,7 @@ public class LivingArmourHandler
|
||||||
ItemArrow itemarrow = (ItemArrow) ((stack.getItem() instanceof ItemArrow ? arrowStack.getItem() : Items.ARROW));
|
ItemArrow itemarrow = (ItemArrow) ((stack.getItem() instanceof ItemArrow ? arrowStack.getItem() : Items.ARROW));
|
||||||
EntityArrow entityarrow = itemarrow.createArrow(world, arrowStack, player);
|
EntityArrow entityarrow = itemarrow.createArrow(world, arrowStack, player);
|
||||||
entityarrow.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
|
entityarrow.shoot(player, player.rotationPitch, player.rotationYaw, 0.0F, velocity * 3.0F, 1.0F);
|
||||||
|
entityarrow.addTag("arrow_shot");
|
||||||
float velocityModifier = 0.6f * velocity;
|
float velocityModifier = 0.6f * velocity;
|
||||||
|
|
||||||
entityarrow.motionX += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
|
entityarrow.motionX += (event.getWorld().rand.nextDouble() - 0.5) * velocityModifier;
|
||||||
|
@ -372,4 +375,19 @@ public class LivingArmourHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Applies: Arrow Shot
|
||||||
|
@SubscribeEvent
|
||||||
|
public static void onProjectileImpact(ProjectileImpactEvent.Arrow event)
|
||||||
|
{
|
||||||
|
if (event.getArrow().removeTag("arrow_shot"))
|
||||||
|
{
|
||||||
|
Entity entity = event.getRayTraceResult().entityHit;
|
||||||
|
|
||||||
|
if (entity != null)
|
||||||
|
{
|
||||||
|
entity.hurtResistantTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue