/** * Renders broken item particles using the given ItemStack */ public void renderBrokenItemStack(ItemStack stack) { this.playSound(SoundEvents.ENTITY_ITEM_BREAK, 0.8F, 0.8F + this.world.rand.nextFloat() * 0.4F); for (int i = 0; i < 5; ++i) { Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F); vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F); double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D; Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D); vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F); vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F); vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ); this.world.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())}); } }
private void generateBranch(World world, Random rand, BlockPos trunkPos, Vec3d endPos) { Vec3d curr = new Vec3d(trunkPos); Vec3d next = next(world, curr, endPos.subtract(curr).normalize(), endPos, trunkPos); BlockPos prev; do { BlockPos currBlock = new BlockPos(curr); Vec3d dir = endPos.subtract(curr).normalize(); prev = currBlock; curr = next; next = next(world, curr, dir, endPos, trunkPos); IBlockState state = (xzEqual(currBlock, trunkPos) ? LOG : LOG.withProperty(BlockLog.LOG_AXIS, getLogAxis(world, currBlock, dir))); setBlockInWorld(world, currBlock, state); // check to avoid long straight up branches BlockPos nextBlock = new BlockPos(next); if (endPos.squareDistanceTo(next) > Math.sqrt(3) && xzEqual(prev, currBlock) && xzEqual(currBlock, nextBlock)) { next = next.addVector(rand.nextBoolean() ? -1 : 1, 0, rand.nextBoolean() ? -1 : 1); } } while (endPos.squareDistanceTo(curr) > Math.sqrt(3)); generateLeaves(world, rand, curr); generateLeaves(world, rand, new Vec3d(prev)); }
@Override public void onExecutionStart(EntityPlayer player) { if (player.getActiveItemStack().isEmpty()) { return; } Vec3d look = player.getLookVec().scale(5); Vec3d pos = player.getPositionVector(); List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class); EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player); if (assumedToBeLookedAt != null) { if (!player.world.isRemote) { assumedToBeLookedAt.addPotionEffect(new PotionEffect(ExPPotions.stunned, 40, 0, false, false)); } player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_KNOCKBACK, SoundCategory.PLAYERS, 1, 0.1F); Vec3d targetPos = assumedToBeLookedAt.getPositionVector(); assumedToBeLookedAt.knockBack(player, 2, pos.x - targetPos.x, pos.z - targetPos.z); } player.getActiveItemStack().damageItem(3, player); }
protected void pathFollow() { Vec3d vec3d = this.getEntityPosition(); float f = this.theEntity.width * this.theEntity.width; int i = 6; if (vec3d.squareDistanceTo(this.currentPath.getVectorFromIndex(this.theEntity, this.currentPath.getCurrentPathIndex())) < (double)f) { this.currentPath.incrementPathIndex(); } for (int j = Math.min(this.currentPath.getCurrentPathIndex() + 6, this.currentPath.getCurrentPathLength() - 1); j > this.currentPath.getCurrentPathIndex(); --j) { Vec3d vec3d1 = this.currentPath.getVectorFromIndex(this.theEntity, j); if (vec3d1.squareDistanceTo(vec3d) <= 36.0D && this.isDirectPathBetweenPoints(vec3d, vec3d1, 0, 0, 0)) { this.currentPath.setCurrentPathIndex(j); break; } } this.checkForStuck(vec3d); }
@Override @SideOnly(Side.CLIENT) public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) { // generateLightBrightnessTable(); // float f = MathHelper.cos(p_76562_1_ * ((float)Math.PI * 2F)) * 2.0F + 0.5F; // f = MathHelper.clamp(f, 0.0F, 1.0F); // int color = 0; // float f1 = ((color >> 16) & 0xFF) * 255; // float f2 = ((color >> 8) & 0xFF) * 255; // float f3 = ((color >> 0) & 0xFF) * 255; // f1 = f1 * (f * 0.0F + 0.15F); // f2 = f2 * (f * 0.0F + 0.15F); // f3 = f3 * (f * 0.0F + 0.15F); // return new Vec3d((double)f1, (double)f2, (double)f3); return Vec3d.ZERO; }
/** * Updates the task */ public void updateTask() { --this.playTime; if (this.targetVillager != null) { if (this.villagerObj.getDistanceSqToEntity(this.targetVillager) > 4.0D) { this.villagerObj.getNavigator().tryMoveToEntityLiving(this.targetVillager, this.speed); } } else if (this.villagerObj.getNavigator().noPath()) { Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.villagerObj, 16, 3); if (vec3d == null) { return; } this.villagerObj.getNavigator().tryMoveToXYZ(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord, this.speed); } }
/** * Returns true if an entity does not collide with any solid blocks at the position. */ private boolean isPositionClear(int p_179692_1_, int p_179692_2_, int p_179692_3_, int p_179692_4_, int p_179692_5_, int p_179692_6_, Vec3d p_179692_7_, double p_179692_8_, double p_179692_10_) { for (BlockPos blockpos : BlockPos.getAllInBox(new BlockPos(p_179692_1_, p_179692_2_, p_179692_3_), new BlockPos(p_179692_1_ + p_179692_4_ - 1, p_179692_2_ + p_179692_5_ - 1, p_179692_3_ + p_179692_6_ - 1))) { double d0 = (double)blockpos.getX() + 0.5D - p_179692_7_.xCoord; double d1 = (double)blockpos.getZ() + 0.5D - p_179692_7_.zCoord; if (d0 * p_179692_8_ + d1 * p_179692_10_ >= 0.0D) { Block block = this.worldObj.getBlockState(blockpos).getBlock(); if (!block.isPassable(this.worldObj, blockpos)) { return false; } } } return true; }
/** * Marks the entity as being inside a portal, activating teleportation logic in onEntityUpdate() in the following * tick(s). */ public void setPortal(BlockPos pos) { if (this.timeUntilPortal > 0) { this.timeUntilPortal = this.getPortalCooldown(); } else { if (!this.worldObj.isRemote && !pos.equals(this.lastPortalPos)) { this.lastPortalPos = new BlockPos(pos); BlockPattern.PatternHelper blockpattern$patternhelper = Blocks.PORTAL.createPatternHelper(this.worldObj, this.lastPortalPos); double d0 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? (double)blockpattern$patternhelper.getFrontTopLeft().getZ() : (double)blockpattern$patternhelper.getFrontTopLeft().getX(); double d1 = blockpattern$patternhelper.getForwards().getAxis() == EnumFacing.Axis.X ? this.posZ : this.posX; d1 = Math.abs(MathHelper.pct(d1 - (double)(blockpattern$patternhelper.getForwards().rotateY().getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE ? 1 : 0), d0, d0 - (double)blockpattern$patternhelper.getWidth())); double d2 = MathHelper.pct(this.posY - 1.0D, (double)blockpattern$patternhelper.getFrontTopLeft().getY(), (double)(blockpattern$patternhelper.getFrontTopLeft().getY() - blockpattern$patternhelper.getHeight())); this.lastPortalVec = new Vec3d(d1, d2, 0.0D); this.teleportDirection = blockpattern$patternhelper.getForwards(); } this.inPortal = true; } }
/** * Returns whether the EntityAIBase should begin execution. */ public boolean shouldExecute() { if (!this.horseHost.isTame() && this.horseHost.isBeingRidden()) { Vec3d vec3d = RandomPositionGenerator.findRandomTarget(this.horseHost, 5, 4); if (vec3d == null) { return false; } else { this.targetX = vec3d.xCoord; this.targetY = vec3d.yCoord; this.targetZ = vec3d.zCoord; return true; } } else { return false; } }
/** * Renders broken item particles using the given ItemStack */ public void renderBrokenItemStack(ItemStack stack) { this.playSound(SoundEvents.ENTITY_ITEM_BREAK, 0.8F, 0.8F + this.worldObj.rand.nextFloat() * 0.4F); for (int i = 0; i < 5; ++i) { Vec3d vec3d = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D); vec3d = vec3d.rotatePitch(-this.rotationPitch * 0.017453292F); vec3d = vec3d.rotateYaw(-this.rotationYaw * 0.017453292F); double d0 = (double)(-this.rand.nextFloat()) * 0.6D - 0.3D; Vec3d vec3d1 = new Vec3d(((double)this.rand.nextFloat() - 0.5D) * 0.3D, d0, 0.6D); vec3d1 = vec3d1.rotatePitch(-this.rotationPitch * 0.017453292F); vec3d1 = vec3d1.rotateYaw(-this.rotationYaw * 0.017453292F); vec3d1 = vec3d1.addVector(this.posX, this.posY + (double)this.getEyeHeight(), this.posZ); this.worldObj.spawnParticle(EnumParticleTypes.ITEM_CRACK, vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, vec3d.xCoord, vec3d.yCoord + 0.05D, vec3d.zCoord, new int[] {Item.getIdFromItem(stack.getItem())}); } }
private void renderBase(int xPos, int yPos, float scale, float rotX, float rotY) { GL11.glPushMatrix(); GL11.glTranslatef(xPos, yPos, 200.0F); GL11.glScalef(-scale, scale, scale); GL11.glRotatef(-180.0F, 1.0F, 0.0F, 0.0F); GL11.glRotatef(-180.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-((float)Math.atan((double)(rotY / 40.0F))) * 20.0F + verticalRotation , 1.0F, 0.0F, 0.0F); GL11.glRotatef(((float)Math.atan((double)(rotX / 40.0F))) * 20.0F + horizontalRotation, 0.0F, -1.0F, 0.0F); GL11.glTranslatef(gridMinX + 0.5F, 0, gridMinZ + 0.5F); for(int z = gridMinZ; z < gridMaxZ; z++) { for(int x = gridMinX; x < gridMaxX; x++) { GL11.glPushMatrix(); drawRect(new Vec3d(0.5, 0, -0.5), new Vec3d(-0.5, 0, -0.5), new Vec3d(0.5, 0, 0.5), new Vec3d(-0.5, 0, 0.5), 0xFF0000, 0.5f, 2.0f); GL11.glPopMatrix(); GL11.glTranslatef(1.0F, 0.0F, 0.0F); } GL11.glTranslatef(gridMinX - gridMaxX, 0.0F, 1.0F); } GL11.glPopMatrix(); }
@Override protected void tick() { if(!checkForCompleation(true) && isActive()) deactivate(); else if(isActive()) { for(int x = -1; x < 2; x++) for(int z = -1; z < 2; z++) if(!(x == 0 && z == 0)) for(int i = 0; i < 8; i ++) { Vec3d pos = new Vec3d(this.pos.add(x, 0, z)).addVector(randPos(), -0.1, randPos()); HarshenCastle.proxy.spawnParticle(EnumHarshenParticle.BLOOD, pos, new Vec3d((this.pos.getX() + 0.5 - pos.x) / 20D, (this.pos.getY() + 0.5 - pos.y) / 20D, (this.pos.getZ() + 0.5 - pos.z) / 20D), 1f, false); } } else if(checkForCompleation(false)) activateRecipe(); }
@Nullable public RayTraceResult rayTrace(double blockReachDistance, float partialTicks) { Vec3d vec3d = this.getPositionEyes(partialTicks); Vec3d vec3d1 = this.getLook(partialTicks); Vec3d vec3d2 = vec3d.addVector(vec3d1.xCoord * blockReachDistance, vec3d1.yCoord * blockReachDistance, vec3d1.zCoord * blockReachDistance); return this.world.rayTraceBlocks(vec3d, vec3d2, false, false, true); }
/** Can the entity be seen? */ private boolean canEntityBeSeen(Entity e, BlockPos pos) { if(!(e instanceof EntityPlayer && ((EntityPlayer)e).capabilities.disableDamage)) { Vec3d pos2 = new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5); return e.world.rayTraceBlocks(new Vec3d(pos2.x + 1, pos2.y, pos2.z + 0), new Vec3d(e.posX, e.posY + e.getEyeHeight(), e.posZ)) == null || e.world.rayTraceBlocks(new Vec3d(pos2.x + 0, pos2.y, pos2.z + 1), new Vec3d(e.posX, e.posY + e.getEyeHeight(), e.posZ)) == null || e.world.rayTraceBlocks(new Vec3d(pos2.x - 1, pos2.y, pos2.z + 0), new Vec3d(e.posX, e.posY + e.getEyeHeight(), e.posZ)) == null || e.world.rayTraceBlocks(new Vec3d(pos2.x + 0, pos2.y, pos2.z - 1), new Vec3d(e.posX, e.posY + e.getEyeHeight(), e.posZ)) == null; } else { return false; } }
public static float getAngleToClientRotation(Vec3d vec) { float[] needed = getNeededRotations(vec); float diffYaw = WMath.wrapDegrees(WMinecraft.getPlayer().rotationYaw) - needed[0]; float diffPitch = WMath.wrapDegrees(WMinecraft.getPlayer().rotationPitch) - needed[1]; float angle = (float)Math.sqrt(diffYaw * diffYaw + diffPitch * diffPitch); return angle; }
/** * Handles right clicking an entity from the entities side, sends a packet to the server. */ public EnumActionResult interactWithEntity(EntityPlayer player, Entity target, RayTraceResult raytrace, @Nullable ItemStack heldItem, EnumHand hand) { this.syncCurrentPlayItem(); Vec3d vec3d = new Vec3d(raytrace.hitVec.xCoord - target.posX, raytrace.hitVec.yCoord - target.posY, raytrace.hitVec.zCoord - target.posZ); this.connection.sendPacket(new CPacketUseEntity(target, hand, vec3d)); if(net.minecraftforge.common.ForgeHooks.onInteractEntityAt(player, target, raytrace, player.getHeldItem(hand), hand)) return EnumActionResult.PASS; return this.currentGameType == GameType.SPECTATOR ? EnumActionResult.PASS : target.applyPlayerInteraction(player, vec3d, heldItem, hand); }
@Override public void onUpdateNavigation() { if (isGoingToTeleport()) { if (teleportCounter == 0 || teleportCounter == 60) { NetworkHandler.sendToAllAround(new PacketPlaySound(Sounds.HUD_INIT, SoundCategory.PLAYERS, pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, 0.1F, teleportCounter == 0 ? 0.7F : 1F, true), pathfindingEntity.world); } if (teleportCounter < TELEPORT_TICKS - 40) { Random rand = pathfindingEntity.getRNG(); float f = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter; float f1 = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter; float f2 = (rand.nextFloat() - 0.5F) * 0.02F * teleportCounter; NetworkHandler.sendToAllAround(new PacketSpawnParticle(EnumParticleTypes.PORTAL, pathfindingEntity.posX, pathfindingEntity.posY, pathfindingEntity.posZ, f, f1, f2), pathfindingEntity.world); } if (++teleportCounter > TELEPORT_TICKS) { if (pathfindingEntity.isBlockValidPathfindBlock(telPos)) { teleport(); } teleportCounter = -1; setPath(null, 0); pathfindingEntity.getMoveHelper().setMoveTo(telPos.getX(), telPos.getY(), telPos.getZ(), pathfindingEntity.getSpeed()); pathfindingEntity.addAir(null, -10000); } } else { // super.onUpdateNavigation(); if (!noPath()) { pathFollow(); if (!noPath()) { Vec3d vec32 = currentPath.getPosition(entity); if (vec32 != null) { entity.getMoveHelper().setMoveTo(vec32.x, vec32.y, vec32.z, speed); } } } } }
private Vec3d getPosition(EntityLivingBase entityLivingBaseIn, double p_177110_2_, float p_177110_4_) { double d0 = entityLivingBaseIn.lastTickPosX + (entityLivingBaseIn.posX - entityLivingBaseIn.lastTickPosX) * (double)p_177110_4_; double d1 = p_177110_2_ + entityLivingBaseIn.lastTickPosY + (entityLivingBaseIn.posY - entityLivingBaseIn.lastTickPosY) * (double)p_177110_4_; double d2 = entityLivingBaseIn.lastTickPosZ + (entityLivingBaseIn.posZ - entityLivingBaseIn.lastTickPosZ) * (double)p_177110_4_; return new Vec3d(d0, d1, d2); }
private void findExitPortal() { Vec3d vec3d = (new Vec3d((double)this.getPos().getX(), 0.0D, (double)this.getPos().getZ())).normalize(); Vec3d vec3d1 = vec3d.scale(1024.0D); for (int i = 16; getChunk(this.worldObj, vec3d1).getTopFilledSegment() > 0 && i-- > 0; vec3d1 = vec3d1.add(vec3d.scale(-16.0D))) { LOG.debug("Skipping backwards past nonempty chunk at {}", new Object[] {vec3d1}); } for (int j = 16; getChunk(this.worldObj, vec3d1).getTopFilledSegment() == 0 && j-- > 0; vec3d1 = vec3d1.add(vec3d.scale(16.0D))) { LOG.debug("Skipping forward past empty chunk at {}", new Object[] {vec3d1}); } LOG.debug("Found chunk at {}", new Object[] {vec3d1}); Chunk chunk = getChunk(this.worldObj, vec3d1); this.exitPortal = findSpawnpointInChunk(chunk); if (this.exitPortal == null) { this.exitPortal = new BlockPos(vec3d1.xCoord + 0.5D, 75.0D, vec3d1.zCoord + 0.5D); LOG.debug("Failed to find suitable block, settling on {}", new Object[] {this.exitPortal}); (new WorldGenEndIsland()).generate(this.worldObj, new Random(this.exitPortal.toLong()), this.exitPortal); } else { LOG.debug("Found block at {}", new Object[] {this.exitPortal}); } this.exitPortal = findHighestBlock(this.worldObj, this.exitPortal, 16, true); LOG.debug("Creating portal at {}", new Object[] {this.exitPortal}); this.exitPortal = this.exitPortal.up(10); this.createExitPortal(this.exitPortal); this.markDirty(); }
public static boolean faceEntityClient(Entity entity) { // get position & rotation Vec3d eyesPos = getEyesPos(); Vec3d lookVec = getServerLookVec(); // try to face center of boundingBox AxisAlignedBB bb = entity.boundingBox; if(faceVectorClient(bb.getCenter())) return true; // if not facing center, check if facing anything in boundingBox return bb.calculateIntercept(eyesPos, eyesPos.add(lookVec.scale(6))) != null; }
@Nullable /** * ray traces all blocks, including non-collideable ones */ public RayTraceResult rayTraceBlocks(Vec3d start, Vec3d end) { return this.rayTraceBlocks(start, end, false, false, false); }
public static boolean lookingAt(EntityLivingBase entity, double max, double targetX, double targetY, double targetZ) { /*double d0 = targetX - entity.posX; double d1 = targetY - (entity.posY + entity.getEyeHeight()); double d2 = targetZ - entity.posZ; double d3 = MathHelper.sqrt(d0 * d0 + d2 * d2); float f = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; float f1 = (float) (-(Math.atan2(d1, d3) * 180.0D / Math.PI)); float compareyaw = Math.abs(180 - Math.abs(Math.abs(f - MathHelper.wrapDegrees(entity.rotationYawHead)) - 180)); float comparepitch = Math.abs(180 - Math.abs(Math.abs(f1 - entity.rotationPitch) - 180)); // System.out.println("Angl: "+compareyaw+" "+comparepitch); return compareyaw < max && comparepitch < max;*/ return TF2Util.isLyingInCone(new Vec3d(targetX, targetY, targetZ),entity.getPositionEyes(1),entity.getPositionEyes(1).add(entity.getLook(1)),(float) Math.toRadians(max)); }
/** * Return Vec3D with biome specific fog color */ @SideOnly(Side.CLIENT) public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) { int i = 10518688; float f = MathHelper.cos(p_76562_1_ * ((float)Math.PI * 2F)) * 2.0F + 0.5F; f = MathHelper.clamp_float(f, 0.0F, 1.0F); float f1 = 0.627451F; float f2 = 0.5019608F; float f3 = 0.627451F; f1 = f1 * (f * 0.0F + 0.15F); f2 = f2 * (f * 0.0F + 0.15F); f3 = f3 * (f * 0.0F + 0.15F); return new Vec3d((double)f1, (double)f2, (double)f3); }
public void attackDirect(Entity target, double pushForce) { if (!this.world.isRemote) { if (!this.hitEntities.contains(target)) { this.hitEntities.add(target); float distance = (float) TF2Util.getDistanceBox(this.shootingEntity, target.posX, target.posY, target.posZ, target.width+0.1, target.height+0.1); int critical = TF2Util.calculateCritPost(target, shootingEntity, this.getCritical(), this.usedWeapon); float dmg = TF2Util.calculateDamage(target, world, this.shootingEntity, usedWeapon, critical, distance); boolean proceed=((ItemProjectileWeapon)this.usedWeapon.getItem()).onHit(usedWeapon, this.shootingEntity, target, dmg, critical); if(!proceed || TF2Util.dealDamage(target, this.world, this.shootingEntity, this.usedWeapon, critical, dmg, TF2Util.causeBulletDamage(this.usedWeapon, this.shootingEntity, critical, this))) { if (!((ItemWeapon) this.usedWeapon.getItem()).canPenetrate(this.usedWeapon,this.shootingEntity)) this.setDead(); if(proceed) { Vec3d pushvec=new Vec3d(this.motionX,this.motionY,this.motionZ).normalize(); pushvec=pushvec.scale(((ItemWeapon) this.usedWeapon.getItem()).getWeaponKnockback(this.usedWeapon, shootingEntity) * 0.01625D*dmg); if(target instanceof EntityLivingBase) { pushvec=pushvec.scale(1-((EntityLivingBase) target).getAttributeMap().getAttributeInstance(SharedMonsterAttributes.KNOCKBACK_RESISTANCE) .getAttributeValue()); } target.addVelocity(pushvec.x, pushvec.y, pushvec.z); target.isAirBorne = target.isAirBorne || -(pushvec.y) > 0.02D; if(target instanceof EntityPlayerMP) TF2weapons.network.sendTo(new TF2Message.VelocityAddMessage(pushvec,target.isAirBorne), (EntityPlayerMP) target); } } } } }
@Override public void render(TileEntityInfernalSmelter te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) { GlStateManager.pushMatrix(); GlStateManager.translate(x, y, z); GlStateManager.disableRescaleNormal(); te.frameAge++; IItemHandler cap = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); Vec3d ore = new Vec3d(0,0.25,0); switch(te.getWorld().getBlockState(te.getPos()).getValue(BlockInfernalSmelter.FACING).getHorizontalIndex()) { case 0: ore = ore.addVector(0.5,0,0.135); break; case 1: ore = ore.addVector(0.85, 0, 0.5); break; case 2: ore = ore.addVector(0.5,0,0.85); break; case 3: ore = ore.addVector(0.135, 0, 0.5); break; } GlStateManager.translate(ore.x,ore.y,ore.z); renderItem(te, cap.getStackInSlot(TileEntityInfernalSmelter.ORE), te.frameAge, false); GlStateManager.popMatrix(); }
/** * Gives the phase a chance to update its status. * Called by dragon's onLivingUpdate. Only used when !worldObj.isRemote. */ public void doLocalUpdate() { if (this.targetLocation == null) { this.targetLocation = new Vec3d(this.dragon.world.getTopSolidOrLiquidBlock(WorldGenEndPodium.END_PODIUM_LOCATION)); } if (this.targetLocation.squareDistanceTo(this.dragon.posX, this.dragon.posY, this.dragon.posZ) < 1.0D) { ((PhaseSittingFlaming)this.dragon.getPhaseManager().getPhase(PhaseList.SITTING_FLAMING)).resetFlameCount(); this.dragon.getPhaseManager().setPhase(PhaseList.SITTING_SCANNING); } }
public void setPlayerLocation(double x, double y, double z, float yaw, float pitch, Set<SPacketPlayerPosLook.EnumFlags> relativeSet) { double d0 = relativeSet.contains(SPacketPlayerPosLook.EnumFlags.X) ? this.playerEntity.posX : 0.0D; double d1 = relativeSet.contains(SPacketPlayerPosLook.EnumFlags.Y) ? this.playerEntity.posY : 0.0D; double d2 = relativeSet.contains(SPacketPlayerPosLook.EnumFlags.Z) ? this.playerEntity.posZ : 0.0D; this.targetPos = new Vec3d(x + d0, y + d1, z + d2); float f = yaw; float f1 = pitch; if (relativeSet.contains(SPacketPlayerPosLook.EnumFlags.Y_ROT)) { f = yaw + this.playerEntity.rotationYaw; } if (relativeSet.contains(SPacketPlayerPosLook.EnumFlags.X_ROT)) { f1 = pitch + this.playerEntity.rotationPitch; } if (++this.teleportId == Integer.MAX_VALUE) { this.teleportId = 0; } this.lastPositionUpdate = this.networkTickCount; this.playerEntity.setPositionAndRotation(this.targetPos.xCoord, this.targetPos.yCoord, this.targetPos.zCoord, f, f1); this.playerEntity.connection.sendPacket(new SPacketPlayerPosLook(x, y, z, yaw, pitch, relativeSet, this.teleportId)); }
public SPacketExplosion(double xIn, double yIn, double zIn, float strengthIn, List<BlockPos> affectedBlockPositionsIn, Vec3d motion) { this.posX = xIn; this.posY = yIn; this.posZ = zIn; this.strength = strengthIn; this.affectedBlockPositions = Lists.newArrayList(affectedBlockPositionsIn); if (motion != null) { this.motionX = (float)motion.xCoord; this.motionY = (float)motion.yCoord; this.motionZ = (float)motion.zCoord; } }
@Nullable @SideOnly(Side.CLIENT) public RayTraceResult rayTrace(double blockReachDistance, float partialTicks) { Vec3d vec3d = this.getPositionEyes(partialTicks); Vec3d vec3d1 = this.getLook(partialTicks); Vec3d vec3d2 = vec3d.addVector(vec3d1.xCoord * blockReachDistance, vec3d1.yCoord * blockReachDistance, vec3d1.zCoord * blockReachDistance); return this.worldObj.rayTraceBlocks(vec3d, vec3d2, false, false, true); }
/** * Return Vec3D with biome specific fog color */ public Vec3d getFogColor(float p_76562_1_, float p_76562_2_) { float f = MathHelper.cos(p_76562_1_ * ((float)Math.PI * 2F)) * 2.0F + 0.5F; f = MathHelper.clamp(f, 0.0F, 1.0F); float f1 = 0.7529412F; float f2 = 0.84705883F; float f3 = 1.0F; f1 = f1 * (f * 0.94F + 0.06F); f2 = f2 * (f * 0.94F + 0.06F); f3 = f3 * (f * 0.91F + 0.09F); return new Vec3d((double)f1, (double)f2, (double)f3); }
private void findNewTarget() { if (this.currentPath == null || this.currentPath.isFinished()) { int i = this.dragon.initPathPoints(); BlockPos blockpos = this.dragon.world.getTopSolidOrLiquidBlock(WorldGenEndPodium.END_PODIUM_LOCATION); EntityPlayer entityplayer = this.dragon.world.getNearestAttackablePlayer(blockpos, 128.0D, 128.0D); int j; if (entityplayer != null) { Vec3d vec3d = (new Vec3d(entityplayer.posX, 0.0D, entityplayer.posZ)).normalize(); j = this.dragon.getNearestPpIdx(-vec3d.xCoord * 40.0D, 105.0D, -vec3d.zCoord * 40.0D); } else { j = this.dragon.getNearestPpIdx(40.0D, (double)blockpos.getY(), 0.0D); } PathPoint pathpoint = new PathPoint(blockpos.getX(), blockpos.getY(), blockpos.getZ()); this.currentPath = this.dragon.findPath(i, j, pathpoint); if (this.currentPath != null) { this.currentPath.incrementPathIndex(); } } this.navigateToNextPathNode(); if (this.currentPath != null && this.currentPath.isFinished()) { this.dragon.getPhaseManager().setPhase(PhaseList.LANDING); } }
/** * Gives the phase a chance to update its status. * Called by dragon's onLivingUpdate. Only used when !worldObj.isRemote. */ public void doLocalUpdate() { if (this.targetLocation == null) { this.targetLocation = new Vec3d(this.dragon.worldObj.getTopSolidOrLiquidBlock(WorldGenEndPodium.END_PODIUM_LOCATION)); } if (this.targetLocation.squareDistanceTo(this.dragon.posX, this.dragon.posY, this.dragon.posZ) < 1.0D) { ((PhaseSittingFlaming)this.dragon.getPhaseManager().getPhase(PhaseList.SITTING_FLAMING)).resetFlameCount(); this.dragon.getPhaseManager().setPhase(PhaseList.SITTING_SCANNING); } }
@Override public Vec3d getSkyColor(Entity entityIn, float partialTicks) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.getSkyColor(entityIn, partialTicks); } else if (m_realWorld != null) { return m_realWorld.getSkyColor(entityIn, partialTicks); } else { return super.getSkyColor(entityIn, partialTicks); } }
@Nullable protected Vec3d getPosition() { if (this.entity.isInWater()) { Vec3d vec3d = RandomPositionGenerator.getLandPos(this.entity, 15, 7); return vec3d == null ? super.getPosition() : vec3d; } else { return this.entity.getRNG().nextFloat() >= this.probability ? RandomPositionGenerator.getLandPos(this.entity, 10, 7) : super.getPosition(); } }
private static List<Predicate<Entity>> getRadiusPredicates(Map<String, String> params, final Vec3d pos) { double d0 = (double)parseIntWithDefault(params, "rm", -1); double d1 = (double)parseIntWithDefault(params, "r", -1); final boolean flag = d0 < -0.5D; final boolean flag1 = d1 < -0.5D; if (flag && flag1) { return Collections.<Predicate<Entity>>emptyList(); } else { double d2 = Math.max(d0, 1.0E-4D); final double d3 = d2 * d2; double d4 = Math.max(d1, 1.0E-4D); final double d5 = d4 * d4; return Lists.<Predicate<Entity>>newArrayList(new Predicate[] {new Predicate<Entity>() { public boolean apply(@Nullable Entity p_apply_1_) { if (p_apply_1_ == null) { return false; } else { double d6 = pos.squareDistanceTo(p_apply_1_.posX, p_apply_1_.posY, p_apply_1_.posZ); return (flag || d6 >= d3) && (flag1 || d6 <= d5); } } } }); } }
@Override public RayTraceResult rayTraceBlocks(Vec3d vec31, Vec3d vec32, boolean stopOnLiquid, boolean ignoreBlockWithoutBoundingBox, boolean returnLastUncollidableBlock) { if (m_proxyWorld != null && Util.isPrefixInCallStack(m_modPrefix)) { return m_proxyWorld.rayTraceBlocks(vec31, vec32, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock); } else if (m_realWorld != null) { return m_realWorld.rayTraceBlocks(vec31, vec32, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock); } else { return super.rayTraceBlocks(vec31, vec32, stopOnLiquid, ignoreBlockWithoutBoundingBox, returnLastUncollidableBlock); } }
@Override public void onCastTick(World world, EntityPlayer player, ItemStack stack) { if (!world.isRemote && world instanceof WorldServer) { Vec3d lookVec = player.getLookVec(); double x = player.posX + lookVec.xCoord; double y = player.posY + lookVec.yCoord + player.eyeHeight; double z = player.posZ + lookVec.zCoord; ((WorldServer) world).spawnParticle(EnumParticleTypes.SMOKE_NORMAL, true, x, y, z, world.rand.nextInt(2), 0.01, 0.01, 0.01, 0); } }
@Nullable /** * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. */ public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end) { return null; }
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb) { for (Template.EntityInfo template$entityinfo : this.entities) { BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos); if (aabb == null || aabb.isVecInside(blockpos)) { NBTTagCompound nbttagcompound = template$entityinfo.entityData; Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn); Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); NBTTagList nbttaglist = new NBTTagList(); nbttaglist.appendTag(new NBTTagDouble(vec3d1.x)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.y)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.z)); nbttagcompound.setTag("Pos", nbttaglist); nbttagcompound.setUniqueId("UUID", UUID.randomUUID()); Entity entity; try { entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn); } catch (Exception var15) { entity = null; } if (entity != null) { float f = entity.getMirroredYaw(mirrorIn); f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn)); entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch); worldIn.spawnEntity(entity); } } } }
private static Vec3d transformedVec3d(Vec3d vec, Mirror mirrorIn, Rotation rotationIn) { double d0 = vec.x; double d1 = vec.y; double d2 = vec.z; boolean flag = true; switch (mirrorIn) { case LEFT_RIGHT: d2 = 1.0D - d2; break; case FRONT_BACK: d0 = 1.0D - d0; break; default: flag = false; } switch (rotationIn) { case COUNTERCLOCKWISE_90: return new Vec3d(d2, d1, 1.0D - d0); case CLOCKWISE_90: return new Vec3d(1.0D - d2, d1, d0); case CLOCKWISE_180: return new Vec3d(1.0D - d0, d1, 1.0D - d2); default: return flag ? new Vec3d(d0, d1, d2) : vec; } }