Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.robotsquid.moltencraft.entity;
- import net.minecraft.block.Block;
- import net.minecraft.entity.Entity;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.entity.projectile.EntityArrow;
- import net.minecraft.util.*;
- import net.minecraft.world.World;
- import java.util.List;
- public class EntityTempLaserBeam extends EntityArrow
- {
- public Entity shootingEntity;
- public EntityTempLaserBeam(World world, EntityLivingBase player, float p_i1756_3_)
- {
- super(world, player, p_i1756_3_);
- }
- @Override
- public void onUpdate()
- {
- int field_145791_d = -1;
- int field_145792_e = -1;
- int field_145789_f = -1;
- this.onEntityUpdate();
- if (this.prevRotationYaw == 0.0F)
- {
- float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
- this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
- }
- Block block = this.worldObj.getBlock(field_145791_d, field_145792_e, field_145789_f);
- Vec3 vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
- Vec3 vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
- MovingObjectPosition movingobjectposition = this.worldObj.func_147447_a(vec31, vec3, false, true, false);
- vec31 = Vec3.createVectorHelper(this.posX, this.posY, this.posZ);
- vec3 = Vec3.createVectorHelper(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ);
- if (movingobjectposition != null)
- {
- vec3 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
- }
- Entity entity = null;
- List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
- double d0 = 0.0D;
- int i;
- float f1;
- for (i = 0; i < list.size(); ++i)
- {
- Entity entity1 = (Entity)list.get(i);
- if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity))
- {
- f1 = 0.3F;
- AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand((double)f1, (double)f1, (double)f1);
- MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3);
- if (movingobjectposition1 != null)
- {
- double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
- if (d1 < d0 || d0 == 0.0D)
- {
- entity = entity1;
- d0 = d1;
- }
- }
- }
- }
- if (entity != null)
- {
- movingobjectposition = new MovingObjectPosition(entity);
- }
- if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer)
- {
- EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit;
- if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer))
- {
- movingobjectposition = null;
- }
- }
- float f2;
- float f4;
- //Hits something
- if (movingobjectposition != null)
- {
- if (movingobjectposition.entityHit != null)
- {
- DamageSource damagesource = null;
- if (this.shootingEntity == null)
- {
- damagesource = DamageSource.causeArrowDamage(this, this);
- }
- else
- {
- damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
- }
- movingobjectposition.entityHit.setFire(5);
- movingobjectposition.entityHit.attackEntityFrom(damagesource, 10.0F);
- }
- this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 1.0F, true);
- this.setDead();
- }
- this.posX += this.motionX;
- this.posY += this.motionY;
- this.posZ += this.motionZ;
- f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
- this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI);
- while (this.rotationYaw - this.prevRotationYaw < -180.0F)
- {
- this.prevRotationYaw -= 360.0F;
- }
- while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
- {
- this.prevRotationYaw += 360.0F;
- }
- this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F;
- float f3 = 0.99F;
- f1 = 0.05F;
- this.motionX *= (double)f3;
- this.motionY *= (double)f3;
- this.motionZ *= (double)f3;
- this.setPosition(this.posX, this.posY, this.posZ);
- this.func_145775_I();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement