public boolean canEntityBeSeen(Entity entity) { return worldObj.rayTraceBlocks( Vec3D.createVector(posX, posY + (double) getEyeHeight(), posZ), Vec3D.createVector( entity.posX, entity.posY + (double) entity.getEyeHeight(), entity.posZ)) == null; }
private void cropScene(Vec3D vA, Vec3D vB, Vec3D vC, int color, boolean fill) { if ((Math.min(Math.min(vA.x, vB.x), vC.x) > 1.0) || (Math.max(Math.max(vA.x, vB.x), vC.x) < -1.0) || (Math.min(Math.min(vA.y, vB.y), vC.y) > 1.0) || (Math.max(Math.max(vA.y, vB.y), vC.y) < -1.0) || (Math.min(Math.min(vA.z, vB.z), vC.z) > 1.0) || (Math.max(Math.max(vA.z, vB.z), vC.z) < 0.0)) { return; } vA = vA.mul(new Vec3D(1.0, -1.0, 1.0)) .add(new Vec3D(1.0, 1.0, 0.0)) .mul(new Vec3D((w - 1) / 2, (h - 1) / 2, 1.0)); vB = vB.mul(new Vec3D(1.0, -1.0, 1.0)) .add(new Vec3D(1.0, 1.0, 0.0)) .mul(new Vec3D((w - 1) / 2, (h - 1) / 2, 1.0)); vC = vC.mul(new Vec3D(1.0, -1.0, 1.0)) .add(new Vec3D(1.0, 1.0, 0.0)) .mul(new Vec3D((w - 1) / 2, (h - 1) / 2, 1.0)); scanLine(vA, vB, vC, color); }
public boolean canSeeNode(Entity entity) { return (worldObj.rayTraceBlocks_do( Vec3D.createVector(posX, posY - yOffset + 0.5, posZ), Vec3D.createVector(entity.posX, entity.posY - entity.yOffset, entity.posZ), false) == null); }
/** * Applies the given transformation matrix to all points in the cloud. * * @param m transformation matrix * @return itself */ public PointCloud3D applyMatrix(Matrix4x4 m) { for (Vec3D p : points) { p.set(m.applyTo(p)); } updateBounds(); return this; }
// through doors etc, from knee to knee height public boolean canEntityBeSeen2(Entity entity) { // System.out.println(getEyeHeight()); return worldObj.rayTraceBlocks_do( Vec3D.createVector(posX, posY - yOffset + 0.7, posZ), Vec3D.createVector(entity.posX, entity.posY - entity.yOffset + 0.7, entity.posZ), false) == null; }
public PointCloud3D addPoint(Vec3D p) { points.add(p); min.minSelf(p); max.maxSelf(p); centroid.set(min.add(max).scaleSelf(0.5f)); radiusSquared = MathUtils.max(radiusSquared, p.distanceToSquared(centroid)); return this; }
// through doors at eye height public boolean canEntityBeSeen3(Entity entity) { return worldObj.rayTraceBlocks_do( Vec3D.createVector(posX, posY - yOffset + (double) getEyeHeight(), posZ), Vec3D.createVector( entity.posX, entity.posY - entity.yOffset + (double) entity.getEyeHeight(), entity.posZ), false) == null; }
public Vec3D getPosition(float f) { if (f == 1.0F) { return Vec3D.createVector(posX, posY, posZ); } else { double d = prevPosX + (posX - prevPosX) * (double) f; double d1 = prevPosY + (posY - prevPosY) * (double) f; double d2 = prevPosZ + (posZ - prevPosZ) * (double) f; return Vec3D.createVector(d, d1, d2); } }
// through doors at knee height, and on the same posy level public boolean canEntityBeSeen4(Entity entity) { // System.out.println((float)((posY-yOffset) - (entity.posY-entity.yOffset))); return (worldObj.rayTraceBlocks_do( Vec3D.createVector(posX, posY - yOffset + 0.7, posZ), Vec3D.createVector(entity.posX, entity.posY - entity.yOffset + 0.7, entity.posZ), false) == null && MathHelper.abs((float) ((posY - yOffset) - (entity.posY - entity.yOffset))) < 1.1F); }
/** * Recalculates the bounding box, bounding sphere and centroid of the cloud. * * @return itself */ public PointCloud3D updateBounds() { min = Vec3D.MAX_VALUE.copy(); max = Vec3D.NEG_MAX_VALUE.copy(); for (Vec3D p : points) { min.minSelf(p); max.maxSelf(p); } centroid.set(min.add(max).scaleSelf(0.5f)); radiusSquared = 0; for (ReadonlyVec3D p : points) { radiusSquared = MathUtils.max(radiusSquared, p.distanceToSquared(centroid)); } return this; }
/** Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { targetEntity = theEntity.getAttackTarget(); if (targetEntity == null) { return false; } if (targetEntity.getDistanceSqToEntity(theEntity) > (double) (field_48218_g * field_48218_g)) { return false; } Vec3D vec3d = RandomPositionGenerator.func_48395_a( theEntity, 16, 7, Vec3D.createVector(targetEntity.posX, targetEntity.posY, targetEntity.posZ)); if (vec3d == null) { return false; } else { movePosX = vec3d.xCoord; movePosY = vec3d.yCoord; movePosZ = vec3d.zCoord; return true; } }
/** Execute a one shot task or start executing a continuous task */ public void startExecuting() { this.insidePosX = -1; if (this.entityObj.getDistanceSq( (double) this.doorInfo.getInsidePosX(), (double) this.doorInfo.posY, (double) this.doorInfo.getInsidePosZ()) > 256.0D) { Vec3D var1 = RandomPositionGenerator.func_48620_a( this.entityObj, 14, 3, Vec3D.createVector( (double) this.doorInfo.getInsidePosX() + 0.5D, (double) this.doorInfo.getInsidePosY(), (double) this.doorInfo.getInsidePosZ() + 0.5D)); if (var1 != null) { this.entityObj.getNavigator().tryMoveToXYZ(var1.xCoord, var1.yCoord, var1.zCoord, 0.3F); } } else { this.entityObj .getNavigator() .tryMoveToXYZ( (double) this.doorInfo.getInsidePosX() + 0.5D, (double) this.doorInfo.getInsidePosY(), (double) this.doorInfo.getInsidePosZ() + 0.5D, 0.3F); } }
public MovingObjectPosition(int par1, int par2, int par3, int par4, Vec3D par5Vec3D) { typeOfHit = EnumMovingObjectType.TILE; blockX = par1; blockY = par2; blockZ = par3; sideHit = par4; hitVec = Vec3D.createVector(par5Vec3D.xCoord, par5Vec3D.yCoord, par5Vec3D.zCoord); }
public Vec3D getLook(float f) { if (f == 1.0F) { float f1 = MathHelper.cos(-rotationYaw * 0.01745329F - 3.141593F); float f3 = MathHelper.sin(-rotationYaw * 0.01745329F - 3.141593F); float f5 = -MathHelper.cos(-rotationPitch * 0.01745329F); float f7 = MathHelper.sin(-rotationPitch * 0.01745329F); return Vec3D.createVector(f3 * f5, f7, f1 * f5); } else { float f2 = prevRotationPitch + (rotationPitch - prevRotationPitch) * f; float f4 = prevRotationYaw + (rotationYaw - prevRotationYaw) * f; float f6 = MathHelper.cos(-f4 * 0.01745329F - 3.141593F); float f8 = MathHelper.sin(-f4 * 0.01745329F - 3.141593F); float f9 = -MathHelper.cos(-f2 * 0.01745329F); float f10 = MathHelper.sin(-f2 * 0.01745329F); return Vec3D.createVector(f8 * f9, f10, f6 * f9); } }
private void g() { Vec3D vec3d = this.h(); int i = this.c.d(); for (int j = this.c.e(); j < this.c.d(); ++j) { if (this.c.a(j).b != (int) vec3d.b) { i = j; break; } } float f = this.a.width * this.a.width; int k; for (k = this.c.e(); k < i; ++k) { if (vec3d.distanceSquared(this.c.a(this.a, k)) < (double) f) { this.c.c(k + 1); } } k = (int) Math.ceil((double) this.a.width); int l = (int) this.a.length + 1; int i1 = k; for (int j1 = i - 1; j1 >= this.c.e(); --j1) { if (this.a(vec3d, this.c.a(this.a, j1), k, l, i1)) { this.c.c(j1); break; } } if (this.g - this.h > 100) { if (vec3d.distanceSquared(this.i) < 2.25D) { this.f(); } this.h = this.g; this.i.a = vec3d.a; this.i.b = vec3d.b; this.i.c = vec3d.c; } }
public static Vec3D projectViewFromEntity(EntityLiving par0EntityLiving, double par1) { double var3 = par0EntityLiving.prevPosX + (par0EntityLiving.posX - par0EntityLiving.prevPosX) * par1; double var5 = par0EntityLiving.prevPosY + (par0EntityLiving.posY - par0EntityLiving.prevPosY) * par1 + (double) par0EntityLiving.getEyeHeight(); double var7 = par0EntityLiving.prevPosZ + (par0EntityLiving.posZ - par0EntityLiving.prevPosZ) * par1; double var9 = var3 + (double) (objectX * 1.0F); double var11 = var5 + (double) (objectY * 1.0F); double var13 = var7 + (double) (objectZ * 1.0F); return Vec3D.createVector(var9, var11, var13); }
/** Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { if (this.targetEntityClass == EntityPlayer.class) { if (this.theEntity instanceof EntityTameable && ((EntityTameable) this.theEntity).isTamed()) { return false; } this.field_48233_d = this.theEntity.worldObj.getClosestPlayerToEntity( this.theEntity, (double) this.field_48234_e); if (this.field_48233_d == null) { return false; } } else { List var1 = this.theEntity.worldObj.getEntitiesWithinAABB( this.targetEntityClass, this.theEntity.boundingBox.expand( (double) this.field_48234_e, 3.0D, (double) this.field_48234_e)); if (var1.size() == 0) { return false; } this.field_48233_d = (Entity) var1.get(0); } if (!this.theEntity.getEntitySenses().canSee(this.field_48233_d)) { return false; } else { Vec3D var2 = RandomPositionGenerator.func_48394_b( this.theEntity, 16, 7, Vec3D.createVector( this.field_48233_d.posX, this.field_48233_d.posY, this.field_48233_d.posZ)); if (var2 == null) { return false; } else if (this.field_48233_d.getDistanceSq(var2.xCoord, var2.yCoord, var2.zCoord) < this.field_48233_d.getDistanceSqToEntity(this.theEntity)) { return false; } else { this.field_48231_f = this.entityPathNavigate.getPathToXYZ(var2.xCoord, var2.yCoord, var2.zCoord); return this.field_48231_f == null ? false : this.field_48231_f.isDestinationSame(var2); } } }
protected void func_35201_a(ItemStack itemstack, int i) { if (itemstack.getItemUseAction() == EnumAction.drink) { worldObj.playSoundAtEntity( this, "random.drink", 0.5F, worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (itemstack.getItemUseAction() == EnumAction.eat) { for (int j = 0; j < i; j++) { Vec3D vec3d = Vec3D.createVector( ((double) rand.nextFloat() - 0.5D) * 0.10000000000000001D, Math.random() * 0.10000000000000001D + 0.10000000000000001D, 0.0D); vec3d.rotateAroundX((-rotationPitch * 3.141593F) / 180F); vec3d.rotateAroundY((-rotationYaw * 3.141593F) / 180F); Vec3D vec3d1 = Vec3D.createVector( ((double) rand.nextFloat() - 0.5D) * 0.29999999999999999D, (double) (-rand.nextFloat()) * 0.59999999999999998D - 0.29999999999999999D, 0.59999999999999998D); vec3d1.rotateAroundX((-rotationPitch * 3.141593F) / 180F); vec3d1.rotateAroundY((-rotationYaw * 3.141593F) / 180F); vec3d1 = vec3d1.addVector(posX, posY + (double) getEyeHeight(), posZ); worldObj.spawnParticle( (new StringBuilder()) .append("iconcrack_") .append(itemstack.getItem().shiftedIndex) .toString(), vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.050000000000000003D, vec3d.zCoord); } worldObj.playSoundAtEntity( this, "random.eat", 0.5F + 0.5F * (float) rand.nextInt(2), (rand.nextFloat() - rand.nextFloat()) * 0.2F + 1.0F); } }
/** * Updates all points in the cloud so that their new centroid is at the given point. * * @param origin new centroid * @return itself */ public PointCloud3D center(ReadonlyVec3D origin) { getCentroid(); Vec3D delta = origin != null ? origin.sub(centroid) : centroid.getInverted(); for (Vec3D p : points) { p.addSelf(delta); } min.addSelf(delta); max.addSelf(delta); centroid.addSelf(delta); return this; }
public Vec3D getFogColor(float f, float f1) { int i = 0x8080a0; float f2 = MathHelper.cos(f * 3.141593F * 2.0F) * 2.0F + 0.5F; if (f2 < 0.0F) { f2 = 0.0F; } if (f2 > 1.0F) { f2 = 1.0F; } float f3 = (float) (i >> 16 & 0xff) / 255F; float f4 = (float) (i >> 8 & 0xff) / 255F; float f5 = (float) (i & 0xff) / 255F; f3 *= f2 * 0.0F + 0.15F; f4 *= f2 * 0.0F + 0.15F; f5 *= f2 * 0.0F + 0.15F; return Vec3D.createVector(f3, f4, f5); }
/** Plays sounds and makes particles for item in use state */ protected void updateItemUse(ItemStack par1ItemStack, int par2) { if (par1ItemStack.getItemUseAction() == EnumAction.drink) { this.worldObj.playSoundAtEntity( this, "random.drink", 0.5F, this.worldObj.rand.nextFloat() * 0.1F + 0.9F); } if (par1ItemStack.getItemUseAction() == EnumAction.eat) { for (int var3 = 0; var3 < par2; ++var3) { Vec3D var4 = Vec3D.createVector( ((double) this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); var4.rotateAroundX(-this.rotationPitch * (float) Math.PI / 180.0F); var4.rotateAroundY(-this.rotationYaw * (float) Math.PI / 180.0F); Vec3D var5 = Vec3D.createVector( ((double) this.rand.nextFloat() - 0.5D) * 0.3D, (double) (-this.rand.nextFloat()) * 0.6D - 0.3D, 0.6D); var5.rotateAroundX(-this.rotationPitch * (float) Math.PI / 180.0F); var5.rotateAroundY(-this.rotationYaw * (float) Math.PI / 180.0F); var5 = var5.addVector(this.posX, this.posY + (double) this.getEyeHeight(), this.posZ); this.worldObj.spawnParticle( "iconcrack_" + par1ItemStack.getItem().shiftedIndex, var5.xCoord, var5.yCoord, var5.zCoord, var4.xCoord, var4.yCoord + 0.05D, var4.zCoord); } this.worldObj.playSoundAtEntity( this, "random.eat", 0.5F + 0.5F * (float) this.rand.nextInt(2), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F); } }
public void func_28002_e() { try { field_28006_b = new byte[0]; renderGlobal.func_28137_f(); } catch (Throwable throwable) { } try { System.gc(); AxisAlignedBB.func_28196_a(); Vec3D.func_28215_a(); } catch (Throwable throwable1) { } try { System.gc(); changeWorld1(null); } catch (Throwable throwable2) { } System.gc(); }
public void doRenderFishHook( EntityFishHook entityfishhook, double d, double d1, double d2, float f, float f1) { GL11.glPushMatrix(); GL11.glTranslatef((float) d, (float) d1, (float) d2); GL11.glEnable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glScalef(0.5F, 0.5F, 0.5F); int i = 1; byte byte0 = 2; loadTexture("/particles.png"); Tessellator tessellator = Tessellator.instance; float f2 = (float) (i * 8 + 0) / 128F; float f3 = (float) (i * 8 + 8) / 128F; float f4 = (float) (byte0 * 8 + 0) / 128F; float f5 = (float) (byte0 * 8 + 8) / 128F; float f6 = 1.0F; float f7 = 0.5F; float f8 = 0.5F; GL11.glRotatef(180F - renderManager.playerViewY, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-renderManager.playerViewX, 1.0F, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.setNormal(0.0F, 1.0F, 0.0F); tessellator.addVertexWithUV(0.0F - f7, 0.0F - f8, 0.0D, f2, f5); tessellator.addVertexWithUV(f6 - f7, 0.0F - f8, 0.0D, f3, f5); tessellator.addVertexWithUV(f6 - f7, 1.0F - f8, 0.0D, f3, f4); tessellator.addVertexWithUV(0.0F - f7, 1.0F - f8, 0.0D, f2, f4); tessellator.draw(); GL11.glDisable(32826 /*GL_RESCALE_NORMAL_EXT*/); GL11.glPopMatrix(); if (entityfishhook.angler != null) { float f9 = ((entityfishhook.angler.prevRotationYaw + (entityfishhook.angler.rotationYaw - entityfishhook.angler.prevRotationYaw) * f1) * 3.141593F) / 180F; double d3 = MathHelper.sin(f9); double d5 = MathHelper.cos(f9); float f11 = entityfishhook.angler.getSwingProgress(f1); float f12 = MathHelper.sin(MathHelper.sqrt_float(f11) * 3.141593F); Vec3D vec3d = Vec3D.createVector(-0.5D, 0.029999999999999999D, 0.80000000000000004D); vec3d.rotateAroundX( (-(entityfishhook.angler.prevRotationPitch + (entityfishhook.angler.rotationPitch - entityfishhook.angler.prevRotationPitch) * f1) * 3.141593F) / 180F); vec3d.rotateAroundY( (-(entityfishhook.angler.prevRotationYaw + (entityfishhook.angler.rotationYaw - entityfishhook.angler.prevRotationYaw) * f1) * 3.141593F) / 180F); vec3d.rotateAroundY(f12 * 0.5F); vec3d.rotateAroundX(-f12 * 0.7F); double d7 = entityfishhook.angler.prevPosX + (entityfishhook.angler.posX - entityfishhook.angler.prevPosX) * (double) f1 + vec3d.xCoord; double d8 = entityfishhook.angler.prevPosY + (entityfishhook.angler.posY - entityfishhook.angler.prevPosY) * (double) f1 + vec3d.yCoord; double d9 = entityfishhook.angler.prevPosZ + (entityfishhook.angler.posZ - entityfishhook.angler.prevPosZ) * (double) f1 + vec3d.zCoord; if (renderManager.options.thirdPersonView > 0) { float f10 = ((entityfishhook.angler.prevRenderYawOffset + (entityfishhook.angler.renderYawOffset - entityfishhook.angler.prevRenderYawOffset) * f1) * 3.141593F) / 180F; double d4 = MathHelper.sin(f10); double d6 = MathHelper.cos(f10); d7 = (entityfishhook.angler.prevPosX + (entityfishhook.angler.posX - entityfishhook.angler.prevPosX) * (double) f1) - d6 * 0.34999999999999998D - d4 * 0.84999999999999998D; d8 = (entityfishhook.angler.prevPosY + (entityfishhook.angler.posY - entityfishhook.angler.prevPosY) * (double) f1) - 0.45000000000000001D; d9 = ((entityfishhook.angler.prevPosZ + (entityfishhook.angler.posZ - entityfishhook.angler.prevPosZ) * (double) f1) - d4 * 0.34999999999999998D) + d6 * 0.84999999999999998D; } double d10 = entityfishhook.prevPosX + (entityfishhook.posX - entityfishhook.prevPosX) * (double) f1; double d11 = entityfishhook.prevPosY + (entityfishhook.posY - entityfishhook.prevPosY) * (double) f1 + 0.25D; double d12 = entityfishhook.prevPosZ + (entityfishhook.posZ - entityfishhook.prevPosZ) * (double) f1; double d13 = (float) (d7 - d10); double d14 = (float) (d8 - d11); double d15 = (float) (d9 - d12); GL11.glDisable(3553 /*GL_TEXTURE_2D*/); GL11.glDisable(2896 /*GL_LIGHTING*/); tessellator.startDrawing(3); tessellator.setColorOpaque_I(0); int j = 16; for (int k = 0; k <= j; k++) { float f13 = (float) k / (float) j; tessellator.addVertex( d + d13 * (double) f13, d1 + d14 * (double) (f13 * f13 + f13) * 0.5D + 0.25D, d2 + d15 * (double) f13); } tessellator.draw(); GL11.glEnable(2896 /*GL_LIGHTING*/); GL11.glEnable(3553 /*GL_TEXTURE_2D*/); } }
@Override public void s_() { K(); BlockPosition blockposition = new BlockPosition(locX, locY, locZ); IBlockData iblockdata = world.getType(blockposition); Block block = iblockdata.getBlock(); if (!ignoredMaterials.contains(Material.getMaterial(Block.getId(block)))) { AxisAlignedBB axisalignedbb = block.a(world, blockposition, iblockdata); if ((axisalignedbb != null) && (axisalignedbb.a(new Vec3D(locX, locY, locZ)))) { float damageMultiplier = MathHelper.sqrt(motX * motX + motY * motY + motZ * motZ); CustomProjectileHitEvent event = new ItemProjectileHitEvent( this, damageMultiplier, world.getWorld().getBlockAt((int) locX, (int) locY, (int) locZ), BlockFace.UP, getItem()); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { die(); } } } age += 1; Vec3D vec3d = new Vec3D(locX, locY, locZ); Vec3D vec3d1 = new Vec3D(locX + motX, locY + motY, locZ + motZ); MovingObjectPosition movingobjectposition = world.rayTrace(vec3d, vec3d1, false, true, false); vec3d = new Vec3D(locX, locY, locZ); vec3d1 = new Vec3D(locX + motX, locY + motY, locZ + motZ); if (movingobjectposition != null) { vec3d1 = new Vec3D( movingobjectposition.pos.a, movingobjectposition.pos.b, movingobjectposition.pos.c); } Entity entity = null; List list = world.getEntities(this, getBoundingBox().a(motX, motY, motZ).grow(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; for (Object aList : list) { Entity entity1 = (Entity) aList; if ((entity1.ad()) && ((entity1 != shooter) || (age >= 5))) { float f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.getBoundingBox().grow(f1, f1, f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.a(vec3d, vec3d1); if (movingobjectposition1 != null) { double d1 = vec3d.distanceSquared(movingobjectposition1.pos); if ((d1 < d0) || (d0 == 0.0D)) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if ((movingobjectposition != null) && (movingobjectposition.entity != null) && ((movingobjectposition.entity instanceof EntityHuman))) { EntityHuman entityhuman = (EntityHuman) movingobjectposition.entity; if ((entityhuman.abilities.isInvulnerable) || (((shooter instanceof EntityHuman)) && (!((EntityHuman) shooter).a(entityhuman)))) { movingobjectposition = null; } } if (movingobjectposition != null) { if (movingobjectposition.entity != null && movingobjectposition.entity instanceof EntityLiving) { float damageMultiplier = MathHelper.sqrt(motX * motX + motY * motY + motZ * motZ); CustomProjectileHitEvent event = new ItemProjectileHitEvent( this, damageMultiplier, (LivingEntity) movingobjectposition.entity.getBukkitEntity(), getItem()); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { if (getKnockback() > 0) { float f4 = MathHelper.sqrt(motX * motX + motZ * motZ); if (f4 > 0.0F) { movingobjectposition.entity.g( motX * getKnockback() * 0.6000000238418579D / f4, 0.1D, motZ * getKnockback() * 0.6000000238418579D / f4); } } die(); } } else if (movingobjectposition.a() != null) { if (!ignoredMaterials.contains(Material.getMaterial(Block.getId(block)))) { motX = ((float) (movingobjectposition.pos.a - locX)); motY = ((float) (movingobjectposition.pos.b - locY)); motZ = ((float) (movingobjectposition.pos.c - locZ)); float f3 = MathHelper.sqrt(motX * motX + motY * motY + motZ * motZ); locX -= motX / f3 * 0.0500000007450581D; locY -= motY / f3 * 0.0500000007450581D; locZ -= motZ / f3 * 0.0500000007450581D; float damageMultiplier = MathHelper.sqrt(motX * motX + motY * motY + motZ * motZ); CustomProjectileHitEvent event = new ItemProjectileHitEvent( this, damageMultiplier, world .getWorld() .getBlockAt( (int) movingobjectposition.pos.a, (int) movingobjectposition.pos.b, (int) movingobjectposition.pos.c), CraftBlock.notchToBlockFace(movingobjectposition.direction), getItem()); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { die(); } } } } locX += motX; locY += motY; locZ += motZ; float f3 = 0.99F; float f1 = 0.05F; motX *= f3; motY *= f3; motZ *= f3; motY -= f1; setPosition(locX, locY, locZ); checkBlockCollisions(); if (isAlive()) { if (this.age >= 1000) { die(); } for (Runnable r : runnables) { r.run(); } for (TypedRunnable<ItemProjectile> r : typedRunnables) { r.run(this); } } }
public MovingObjectPosition(Entity par1Entity) { typeOfHit = EnumMovingObjectType.ENTITY; entityHit = par1Entity; hitVec = Vec3D.createVector(par1Entity.posX, par1Entity.posY, par1Entity.posZ); }
public void onUpdate() { if (!this.worldObj.isRemote && (this.shootingEntity != null && this.shootingEntity.isDead || !this.worldObj.blockExists((int) this.posX, (int) this.posY, (int) this.posZ))) { this.setDead(); } else { super.onUpdate(); this.setFire(1); if (this.inGround) { int var1 = this.worldObj.getBlockId(this.xTile, this.yTile, this.zTile); if (var1 == this.inTile) { ++this.ticksAlive; if (this.ticksAlive == 600) { this.setDead(); } return; } this.inGround = false; this.motionX *= (double) (this.rand.nextFloat() * 0.2F); this.motionY *= (double) (this.rand.nextFloat() * 0.2F); this.motionZ *= (double) (this.rand.nextFloat() * 0.2F); this.ticksAlive = 0; this.ticksInAir = 0; } else { ++this.ticksInAir; } Vec3D var15 = Vec3D.createVector(this.posX, this.posY, this.posZ); Vec3D var2 = Vec3D.createVector( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition var3 = this.worldObj.rayTraceBlocks(var15, var2); var15 = Vec3D.createVector(this.posX, this.posY, this.posZ); var2 = Vec3D.createVector( this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (var3 != null) { var2 = Vec3D.createVector(var3.hitVec.xCoord, var3.hitVec.yCoord, var3.hitVec.zCoord); } Entity var4 = null; List var5 = this.worldObj.getEntitiesWithinAABBExcludingEntity( this, this.boundingBox .addCoord(this.motionX, this.motionY, this.motionZ) .expand(1.0D, 1.0D, 1.0D)); double var6 = 0.0D; for (int var8 = 0; var8 < var5.size(); ++var8) { Entity var9 = (Entity) var5.get(var8); if (var9.canBeCollidedWith() && (!var9.isEntityEqual(this.shootingEntity) || this.ticksInAir >= 25)) { float var10 = 0.3F; AxisAlignedBB var11 = var9.boundingBox.expand((double) var10, (double) var10, (double) var10); MovingObjectPosition var12 = var11.calculateIntercept(var15, var2); if (var12 != null) { double var13 = var15.distanceTo(var12.hitVec); if (var13 < var6 || var6 == 0.0D) { var4 = var9; var6 = var13; } } } } if (var4 != null) { var3 = new MovingObjectPosition(var4); } if (var3 != null) { this.func_40071_a(var3); } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; float var16 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float) (Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float) (Math.atan2(this.motionY, (double) var16) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) {; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; float var17 = 0.95F; if (this.isInWater()) { for (int var19 = 0; var19 < 4; ++var19) { float var18 = 0.25F; this.worldObj.spawnParticle( "bubble", this.posX - this.motionX * (double) var18, this.posY - this.motionY * (double) var18, this.posZ - this.motionZ * (double) var18, this.motionX, this.motionY, this.motionZ); } var17 = 0.8F; } this.motionX += this.accelerationX; this.motionY += this.accelerationY; this.motionZ += this.accelerationZ; this.motionX *= (double) var17; this.motionY *= (double) var17; this.motionZ *= (double) var17; this.worldObj.spawnParticle( "smoke", this.posX, this.posY + 0.5D, this.posZ, 0.0D, 0.0D, 0.0D); this.setPosition(this.posX, this.posY, this.posZ); } }
@Override public void testOutputs(HashMap<Variable, Double> outputs) { assertTrue(outputs.containsKey(new MultivectorComponent("abstand", 0))); assertTrue(outputs.containsKey(new MultivectorComponent("nor", 1))); assertTrue(outputs.containsKey(new MultivectorComponent("nor", 2))); assertTrue(outputs.containsKey(new MultivectorComponent("nor", 3))); // assertTrue(outputs.containsKey(new MultivectorComponent("", ))); double abstand = outputs.get(new MultivectorComponent("abstand", 0)); Vec3D nor = new Vec3D( outputs.get(new MultivectorComponent("nor", 1)), outputs.get(new MultivectorComponent("nor", 2)), outputs.get(new MultivectorComponent("nor", 3))); nor.normalize(); nor.scalarMultiplication(abstand); Point3D pBase = nor.applyToPoint(new Point3D(pTest.x, pTest.y, pTest.z)); // pBase must lie on plane and on line // test if on line, assume that dx,dy,dz not zero double tx = (pBase.x - p1.x) / ((p2.x - p1.x)); double ty = (pBase.y - p1.y) / ((p2.y - p1.y)); double tz = (pBase.z - p1.z) / ((p2.z - p1.z)); // since the normal is unique except of a sign: if (Math.abs(tx - ty) > 0.001 || Math.abs(tz - ty) > 0.001) { nor = new Vec3D( outputs.get(new MultivectorComponent("nor", 1)), outputs.get(new MultivectorComponent("nor", 2)), outputs.get(new MultivectorComponent("nor", 3))); nor.normalize(); nor.scalarMultiplication(-abstand); pBase = nor.applyToPoint(new Point3D(pTest.x, pTest.y, pTest.z)); // pBase must lie on plane and on line // test if on line, assume that dx,dy,dz not zero tx = (pBase.x - p1.x) / ((p2.x - p1.x)); ty = (pBase.y - p1.y) / ((p2.y - p1.y)); tz = (pBase.z - p1.z) / ((p2.z - p1.z)); } assertEquals(tx, ty, 0.001); assertEquals(ty, tz, 0.001); // test if on plane Vec3D r = new Vec3D((p2.x - p1.x), (p2.y - p1.y), (p2.z - p1.z)); r.normalize(); Vec3D xmpTest = new Vec3D(pBase.x - pTest.x, pBase.y - pTest.y, pBase.z - pTest.z); double dp = xmpTest.dotProduct(r); assertEquals(0, dp, 0.001); }
@Override public Double intersect(Ray ray) { Vec3D o = worldToObject.multiplyPoint(ray.origin); o.setY(o.getY() + ymax + (ymin - ymax) * 0.5); Vec3D d = worldToObject.multiplyDirection(ray.direction); double sin2 = radius2 / (radius2 + height * height); double cos2 = 1 - sin2; double a = d.getX() * d.getX() * cos2 + d.getZ() * d.getZ() * cos2 - d.getY() * d.getY() * sin2; double b = 2 * (o.getX() * d.getX() * cos2 + o.getZ() * d.getZ() * cos2 - o.getY() * d.getY() * sin2); double c = o.getX() * o.getX() * cos2 + o.getZ() * o.getZ() * cos2 - o.getY() * o.getY() * sin2; QuadraticRoots roots = Utils.solveQuadratic(a, b, c); boolean isect = false; double t0 = 0, t1 = 0, t = Double.POSITIVE_INFINITY; Vec3D n = new Vec3D(); if (roots != null) { if (roots.x0 > roots.x1) { t0 = roots.x1; t1 = roots.x0; } else { t0 = roots.x0; t1 = roots.x1; } if (t0 < 0) { t0 = t1; } double y = o.getY() + t0 * d.getY(); if (y > ymax || y < ymin) { t0 = t1; y = o.getY() + t0 * d.getY(); } if (y >= ymin && y <= ymax && t0 >= 0) { isect = true; t = t0; Vec3D p = o.add(d.multiply(t0)); Vec3D tangent = new Vec3D(0, 1, 0).crossProduct(new Vec3D(p.getX(), 0, p.getZ())); Vec3D bitangent = p.multiply(-1); n = objectToWorld.multiplyDirection(tangent.crossProduct(bitangent)).normalize(); } t0 = (ymin - o.getY()) / d.getY(); double xx = o.getX() + t0 * d.getX(); double zz = o.getZ() + t0 * d.getZ(); if (xx * xx + zz * zz <= radius2 && t0 < t && t0 >= 0) { isect = true; t = t0; n = objectToWorld.multiplyDirection(new Vec3D(0, -1, 0)); } if (radius0 != 0) { t0 = (ymax - o.getY()) / d.getY(); xx = o.getX() + t0 * d.getX(); zz = o.getZ() + t0 * d.getZ(); if (xx * xx + zz * zz <= radius0 * radius0 && t0 < t && t0 >= 0) { isect = true; t = t0; n = objectToWorld.multiplyDirection(new Vec3D(0, 1, 0)); } } } if (isect) { normal = n; return t; } return null; }
public Vec3D func_182_g(double par1, double par3, double par5) { int i = MathHelper.floor_double(par1); int j = MathHelper.floor_double(par3); int k = MathHelper.floor_double(par5); if (BlockRail.isRailBlockAt(worldObj, i, j - 1, k)) { j--; } int l = worldObj.getBlockId(i, j, k); if (BlockRail.isRailBlock(l)) { int i1 = worldObj.getBlockMetadata(i, j, k); par3 = j; if (((BlockRail) Block.blocksList[l]).isPowered()) { i1 &= 7; } if (i1 >= 2 && i1 <= 5) { par3 = j + 1; } int ai[][] = field_468_ak[i1]; double d = 0.0D; double d1 = (double) i + 0.5D + (double) ai[0][0] * 0.5D; double d2 = (double) j + 0.5D + (double) ai[0][1] * 0.5D; double d3 = (double) k + 0.5D + (double) ai[0][2] * 0.5D; double d4 = (double) i + 0.5D + (double) ai[1][0] * 0.5D; double d5 = (double) j + 0.5D + (double) ai[1][1] * 0.5D; double d6 = (double) k + 0.5D + (double) ai[1][2] * 0.5D; double d7 = d4 - d1; double d8 = (d5 - d2) * 2D; double d9 = d6 - d3; if (d7 == 0.0D) { par1 = (double) i + 0.5D; d = par5 - (double) k; } else if (d9 == 0.0D) { par5 = (double) k + 0.5D; d = par1 - (double) i; } else { double d10 = par1 - d1; double d11 = par5 - d3; double d12 = (d10 * d7 + d11 * d9) * 2D; d = d12; } par1 = d1 + d7 * d; par3 = d2 + d8 * d; par5 = d3 + d9 * d; if (d8 < 0.0D) { par3++; } if (d8 > 0.0D) { par3 += 0.5D; } return Vec3D.createVector(par1, par3, par5); } else { return null; } }
public MovingObjectPosition rayTrace(double d, float f) { Vec3D vec3d = getPosition(f); Vec3D vec3d1 = getLook(f); Vec3D vec3d2 = vec3d.addVector(vec3d1.xCoord * d, vec3d1.yCoord * d, vec3d1.zCoord * d); return worldObj.rayTraceBlocks(vec3d, vec3d2); }