use of net.minecraft.util.AxisAlignedBB in project ClaySoldiersMod by SanAndreasP.
the class EntityFireball method onUpdate.
@Override
public void onUpdate() {
super.onUpdate();
if (prevRotationPitch == 0.0F && prevRotationYaw == 0.0F) {
float f = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
prevRotationYaw = rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
prevRotationPitch = rotationPitch = (float) ((Math.atan2(motionY, f) * 180D) / 3.1415927410125732D);
}
int i = worldObj.getBlockId(xTile, yTile, zTile);
if (i > 0) {
Block.blocksList[i].setBlockBoundsBasedOnState(worldObj, xTile, yTile, zTile);
AxisAlignedBB axisalignedbb = Block.blocksList[i].getCollisionBoundingBoxFromPool(worldObj, xTile, yTile, zTile);
if (axisalignedbb != null && axisalignedbb.isVecInside(Vec3.createVectorHelper(posX, posY, posZ))) {
inGround = true;
}
}
if (arrowShake > 0) {
arrowShake--;
}
if (inGround) {
int j = worldObj.getBlockId(xTile, yTile, zTile);
int k = worldObj.getBlockMetadata(xTile, yTile, zTile);
if (j != inTile || k != field_28019_h) {
inGround = false;
motionX *= rand.nextFloat() * 0.2F;
motionY *= rand.nextFloat() * 0.2F;
motionZ *= rand.nextFloat() * 0.2F;
ticksInGround = 0;
ticksInAir = 0;
return;
}
ticksInGround++;
if (ticksInGround == 1200) {
setDead();
}
return;
}
ticksInAir++;
Vec3 vec3d = Vec3.createVectorHelper(posX, posY, posZ);
Vec3 vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
MovingObjectPosition movingobjectposition = worldObj.rayTraceBlocks_do_do(vec3d, vec3d1, false, true);
vec3d = Vec3.createVectorHelper(posX, posY, posZ);
vec3d1 = Vec3.createVectorHelper(posX + motionX, posY + motionY, posZ + motionZ);
if (movingobjectposition != null) {
vec3d1 = Vec3.createVectorHelper(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);
}
Entity entity = null;
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, boundingBox.addCoord(motionX, motionY, motionZ).expand(1.0D, 1.0D, 1.0D));
double d = 0.0D;
for (int l = 0; l < list.size(); l++) {
Entity entity1 = (Entity) list.get(l);
if (!entity1.canBeCollidedWith() || entity1 == owner && ticksInAir < 5) {
continue;
}
float f4 = 0.3F;
AxisAlignedBB axisalignedbb1 = entity1.boundingBox.expand(f4, f4, f4);
MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec3d, vec3d1);
if (movingobjectposition1 == null) {
continue;
}
double d1 = vec3d.distanceTo(movingobjectposition1.hitVec);
if (d1 < d || d == 0.0D) {
entity = entity1;
d = d1;
}
}
if (entity != null) {
movingobjectposition = new MovingObjectPosition(entity);
}
if (movingobjectposition != null) {
if (movingobjectposition.entityHit != null) {
int attackU = 0;
if (!(movingobjectposition.entityHit instanceof EntityClayMan || movingobjectposition.entityHit instanceof EntityMob)) {
attackU = 2;
} else {
if (movingobjectposition.entityHit instanceof EntityClayMan) {
if (((EntityClayMan) movingobjectposition.entityHit).getClayTeam() == getClayTeam()) {
setDead();
return;
}
}
}
if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, owner), attackU)) {
int fire = 4;
if (owner != null && owner instanceof EntityClayMan) {
// if (((EntityClayMan)owner).hasCoal)
// fire = 8;
}
movingobjectposition.entityHit.setFire(fire);
worldObj.playAuxSFXAtEntity(null, 1009, (int) movingobjectposition.entityHit.posX, (int) movingobjectposition.entityHit.posY, (int) movingobjectposition.entityHit.posZ, 0);
setDead();
}
} else {
xTile = movingobjectposition.blockX;
yTile = movingobjectposition.blockY;
zTile = movingobjectposition.blockZ;
inTile = worldObj.getBlockId(xTile, yTile, zTile);
field_28019_h = worldObj.getBlockMetadata(xTile, yTile, zTile);
motionX = (float) (movingobjectposition.hitVec.xCoord - posX);
motionY = (float) (movingobjectposition.hitVec.yCoord - posY);
motionZ = (float) (movingobjectposition.hitVec.zCoord - posZ);
float f1 = MathHelper.sqrt_double(motionX * motionX + motionY * motionY + motionZ * motionZ);
posX -= (motionX / f1) * 0.05000000074505806D;
posY -= (motionY / f1) * 0.05000000074505806D;
posZ -= (motionZ / f1) * 0.05000000074505806D;
inGround = true;
arrowShake = 7;
}
}
posX += motionX;
posY += motionY;
posZ += motionZ;
float f2 = MathHelper.sqrt_double(motionX * motionX + motionZ * motionZ);
rotationYaw = (float) ((Math.atan2(motionX, motionZ) * 180D) / 3.1415927410125732D);
for (rotationPitch = (float) ((Math.atan2(motionY, f2) * 180D) / 3.1415927410125732D); rotationPitch - prevRotationPitch < -180F; prevRotationPitch -= 360F) {
}
for (; rotationPitch - prevRotationPitch >= 180F; prevRotationPitch += 360F) {
}
for (; rotationYaw - prevRotationYaw < -180F; prevRotationYaw -= 360F) {
}
for (; rotationYaw - prevRotationYaw >= 180F; prevRotationYaw += 360F) {
}
rotationPitch = prevRotationPitch + (rotationPitch - prevRotationPitch) * 0.2F;
rotationYaw = prevRotationYaw + (rotationYaw - prevRotationYaw) * 0.2F;
float f3 = 0.99F;
float f5 = 0.03F;
if (isInWater()) {
for (int i1 = 0; i1 < 4; i1++) {
float f6 = 0.25F;
worldObj.spawnParticle("bubble", posX - motionX * f6, posY - motionY * f6, posZ - motionZ * f6, motionX, motionY, motionZ);
}
f3 = 0.8F;
}
motionX *= f3;
motionY *= f3;
motionZ *= f3;
motionY -= f5;
setPosition(posX, posY, posZ);
if (ticksInGround > 0 || inGround) {
isDead = true;
}
if (isDead) {
double a = posX + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
double b = boundingBox.minY + 0.125D + ((rand.nextFloat() - rand.nextFloat()) * 0.25D);
double c = posZ + ((rand.nextFloat() - rand.nextFloat()) * 0.125D);
CSMModRegistry.proxy.showEffect(this.worldObj, this, 12);
// if (FMLCommonHandler.instance().getSide().isClient())
// CSM_ModRegistry.proxy.showEffect((new EntityDiggingFX(CSM_ModRegistry.proxy.getClientWorld(), a, b, c, 0.0D, 0.0D, 0.0D, Block.gravel, 0, 0)));
worldObj.playSoundAtEntity(this, "step.gravel", 0.6F, 1.0F / (rand.nextFloat() * 0.2F + 0.9F));
}
}
use of net.minecraft.util.AxisAlignedBB in project ClaySoldiersMod by SanAndreasP.
the class EntityPegasusMount method onUpdate.
@Override
public void onUpdate() {
if (this.worldObj.isRemote) {
this.calcWingSwing();
}
this.jumpMovementFactor = this.getAIMoveSpeed() * (0.16277136F / (0.91F * 0.91F * 0.91F));
this.fallDistance = 0.0F;
if (this.motionY < -0.1D) {
this.motionY = -0.1D;
}
if (this.riddenByEntity instanceof EntityClayMan && this.moveForward != 0.0F) {
EntityClayMan rider = (EntityClayMan) this.riddenByEntity;
double dist = Double.MAX_VALUE;
if (rider.getEntityToAttack() != null) {
dist = this.getDistanceSqToEntity(rider.getEntityToAttack());
} else if (rider.getTargetFollowing() != null) {
dist = this.getDistanceSqToEntity(rider.getTargetFollowing());
}
if (dist > 2.25D) {
if (this.onGround) {
this.motionY = 0.4D;
this.isAirBorne = true;
} else {
int[] blockPos = new int[] { (int) posX, (int) posY - 1, (int) posZ };
Block blockBelow = this.worldObj.getBlock(blockPos[0], blockPos[1], blockPos[2]);
if (blockBelow != null && !blockBelow.isAir(this.worldObj, blockPos[0], blockPos[1], blockPos[2])) {
AxisAlignedBB aabb = blockBelow.getCollisionBoundingBoxFromPool(this.worldObj, blockPos[0], blockPos[1], blockPos[2]);
if (aabb == null || aabb.maxY > (this.posY - 1.0D)) {
this.motionY = 0.2D;
this.isAirBorne = true;
}
}
}
}
}
super.onUpdate();
}
use of net.minecraft.util.AxisAlignedBB in project ArsMagica2 by Mithion.
the class MathUtilities method getPointedEntity.
public static Entity getPointedEntity(World world, EntityLivingBase entityplayer, double range, double collideRadius, boolean nonCollide) {
Entity pointedEntity = null;
double d = range;
Vec3 vec3d = Vec3.createVectorHelper(entityplayer.posX, entityplayer.posY + entityplayer.getEyeHeight(), entityplayer.posZ);
Vec3 vec3d1 = entityplayer.getLookVec();
Vec3 vec3d2 = vec3d.addVector(vec3d1.xCoord * d, vec3d1.yCoord * d, vec3d1.zCoord * d);
double f1 = collideRadius;
List list = world.getEntitiesWithinAABBExcludingEntity(entityplayer, entityplayer.boundingBox.addCoord(vec3d1.xCoord * d, vec3d1.yCoord * d, vec3d1.zCoord * d).expand(f1, f1, f1));
double d2 = 0.0D;
for (int i = 0; i < list.size(); i++) {
Entity entity = (Entity) list.get(i);
MovingObjectPosition mop = world.rayTraceBlocks(Vec3.createVectorHelper(entityplayer.posX, entityplayer.posY + entityplayer.getEyeHeight(), entityplayer.posZ), Vec3.createVectorHelper(entity.posX, entity.posY + entity.getEyeHeight(), entity.posZ), false);
if (((entity.canBeCollidedWith()) || (nonCollide)) && mop == null) {
float f2 = Math.max(0.8F, entity.getCollisionBorderSize());
AxisAlignedBB axisalignedbb = entity.boundingBox.expand(f2, f2, f2);
MovingObjectPosition movingobjectposition = axisalignedbb.calculateIntercept(vec3d, vec3d2);
if (axisalignedbb.isVecInside(vec3d)) {
if ((0.0D < d2) || (d2 == 0.0D)) {
pointedEntity = entity;
d2 = 0.0D;
}
} else if (movingobjectposition != null) {
double d3 = vec3d.distanceTo(movingobjectposition.hitVec);
if ((d3 < d2) || (d2 == 0.0D)) {
pointedEntity = entity;
d2 = d3;
}
}
}
}
return pointedEntity;
}
use of net.minecraft.util.AxisAlignedBB in project ArsMagica2 by Mithion.
the class TileEntityKeystoneRecepticle method updateEntity.
@Override
public void updateEntity() {
super.updateEntity();
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(xCoord + 0.3, yCoord - 3, zCoord + 0.3, xCoord + 0.7, yCoord, zCoord + 0.7);
ArrayList<Entity> entities = (ArrayList<Entity>) worldObj.getEntitiesWithinAABB(EntityLivingBase.class, bb);
if (this.isActive) {
surroundingCheckTicks--;
if (surroundingCheckTicks <= 0) {
surroundingCheckTicks = 20;
checkSurroundings();
}
if (entities.size() == 1) {
doTeleport(entities.get(0));
}
} else {
if (entities.size() == 1 && worldObj.canBlockSeeTheSky(xCoord, yCoord, zCoord)) {
Entity entity = entities.get(0);
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (player.isPotionActive(BuffList.haste) && player.isPotionActive(Potion.moveSpeed.id) && player.isSprinting()) {
// if (worldObj.isRemote)
// player.addStat(AMCore.achievements.EightyEightMilesPerHour, 1);
this.key = 0;
if (!worldObj.isRemote) {
EntityLightningBolt elb = new EntityLightningBolt(worldObj, xCoord, yCoord, zCoord);
worldObj.spawnEntityInWorld(elb);
}
doTeleport(player);
}
}
}
}
}
use of net.minecraft.util.AxisAlignedBB in project ArsMagica2 by Mithion.
the class TileEntitySlipstreamGenerator method playerIsValid.
private boolean playerIsValid(EntityPlayer player) {
if (player == null || player.isDead)
return false;
float tolerance = 0.2f;
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(xCoord - tolerance, yCoord + 1, zCoord - tolerance, xCoord + 1 + tolerance, yCoord + 1 + this.EFFECT_HEIGHT, zCoord + 1 + tolerance);
Vec3 myLoc = Vec3.createVectorHelper(xCoord + 0.5, yCoord + 1, zCoord + 0.5);
Vec3 playerLoc = Vec3.createVectorHelper(player.posX, player.posY, player.posZ);
return bb.intersectsWith(player.boundingBox) && worldObj.rayTraceBlocks(myLoc, playerLoc, true) == null;
}
Aggregations