More sigils

Deleted weird file
This commit is contained in:
Arcaratus 2015-12-28 19:09:51 -05:00
parent 0ec0570d1a
commit b96725fe98
31 changed files with 1011 additions and 53 deletions

View file

@ -1,14 +1,19 @@
package WayofTime.bloodmagic.potion;
import WayofTime.bloodmagic.registry.ModPotions;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.Entity;
import net.minecraft.entity.IProjectile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.ArrayList;
import java.util.List;
public class PotionEventHandlers {
@ -31,11 +36,6 @@ public class PotionEventHandlers {
@SubscribeEvent
public void onEntityUpdate(LivingEvent.LivingUpdateEvent event) {
// EntityLivingBase entityLiving = event.entityLiving;
// double x = entityLiving.posX;
// double y = entityLiving.posY;
// double z = entityLiving.posZ;
if (event.entityLiving.isPotionActive(ModPotions.boost)) {
int i = event.entityLiving.getActivePotionEffect(ModPotions.boost).getAmplifier();
@ -51,5 +51,66 @@ public class PotionEventHandlers {
}
}
}
if (event.entityLiving.isPotionActive(ModPotions.whirlwind)) {
int d0 = 3;
AxisAlignedBB axisAlignedBB = AxisAlignedBB.fromBounds(event.entityLiving.posX - 0.5, event.entityLiving.posY - 0.5, event.entityLiving.posZ - 0.5, event.entityLiving.posX + 0.5, event.entityLiving.posY + 0.5, event.entityLiving.posZ + 0.5).expand(d0, d0, d0);
List entityList = event.entityLiving.worldObj.getEntitiesWithinAABB(Entity.class, axisAlignedBB);
for (Object thing : entityList) {
Entity projectile = (Entity) thing;
if (projectile == null) continue;
if (!(projectile instanceof IProjectile)) continue;
Entity throwingEntity = null;
if (projectile instanceof EntityArrow) throwingEntity = ((EntityArrow) projectile).shootingEntity;
else if (projectile instanceof EntityThrowable)
throwingEntity = ((EntityThrowable) projectile).getThrower();
if (throwingEntity != null && throwingEntity.equals(event.entityLiving)) continue;
double delX = projectile.posX - event.entityLiving.posX;
double delY = projectile.posY - event.entityLiving.posY;
double delZ = projectile.posZ - event.entityLiving.posZ;
double angle = (delX * projectile.motionX + delY * projectile.motionY + delZ * projectile.motionZ) /
(Math.sqrt(delX * delX + delY * delY + delZ * delZ) * Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ));
angle = Math.acos(angle);
if (angle < 3 * (Math.PI / 4)) continue; //angle is < 135 degrees
if (throwingEntity != null) {
delX = -projectile.posX + throwingEntity.posX;
delY = -projectile.posY + (throwingEntity.posY + throwingEntity.getEyeHeight());
delZ = -projectile.posZ + throwingEntity.posZ;
}
double curVel = Math.sqrt(delX * delX + delY * delY + delZ * delZ);
delX /= curVel;
delY /= curVel;
delZ /= curVel;
double newVel = Math.sqrt(projectile.motionX * projectile.motionX + projectile.motionY * projectile.motionY + projectile.motionZ * projectile.motionZ);
projectile.motionX = newVel * delX;
projectile.motionY = newVel * delY;
projectile.motionZ = newVel * delZ;
}
}
}
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerDamageEvent(LivingAttackEvent event) {
if (event.entityLiving.isPotionActive(ModPotions.whirlwind) && event.isCancelable() && event.source.isProjectile())
event.setCanceled(true);
}
@SubscribeEvent
public void onEndermanTeleportEvent(EnderTeleportEvent event) {
if (event.entityLiving.isPotionActive(ModPotions.planarBinding) && event.isCancelable()) {
event.setCanceled(true);
}
}
}