Java Code Examples for net.minecraft.util.Vec3#createVectorHelper()
The following examples show how to use
net.minecraft.util.Vec3#createVectorHelper() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WorldProviderRoss128b.java From bartworks with MIT License | 6 votes |
@SideOnly(Side.CLIENT) public Vec3 getFogColor(float cy, float noidea) { float angle = MathHelper.cos(cy * (float) Math.PI * 2.0F) * 2.0F + 0.5F; if (angle < 0.0F) { angle = 0.0F; } if (angle > 1.0F) { angle = 1.0F; } float red = 200 / 255f; float green = 80 / 255f; float blue = 0.0F; red *= angle * 0.94F + 0.06F; green *= angle * 0.94F + 0.06F; return Vec3.createVectorHelper(red, green, blue); }
Example 2
Source File: TileEntitySelector.java From OpenPeripheral-Addons with MIT License | 6 votes |
@Override public boolean onBlockActivated(EntityPlayer player, int side, float hitX, float hitY, float hitZ) { if (worldObj.isRemote) return true; if (player.isSneaking()) return true; Vec3 vec = Vec3.createVectorHelper(xCoord + hitX, yCoord + hitY, zCoord + hitZ); ItemSlot slot = getClickedSlot(vec, side); if (slot == null) { openGui(OpenPeripheralAddons.instance, player); } else { if (hasStack(slot.slot)) signalSlotClick(slot.slot); } return true; }
Example 3
Source File: TileEssentiaCompressor.java From Gadomancy with GNU Lesser General Public License v3.0 | 6 votes |
private void playVortexEffects() { for (int a = 0; a < Thaumcraft.proxy.particleCount(1); a++) { int tx = this.xCoord + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4); int ty = this.yCoord + 1 + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4); int tz = this.zCoord + this.worldObj.rand.nextInt(4) - this.worldObj.rand.nextInt(4); if (ty > this.worldObj.getHeightValue(tx, tz)) { ty = this.worldObj.getHeightValue(tx, tz); } Vec3 v1 = Vec3.createVectorHelper(this.xCoord + 0.5D, this.yCoord + 1.5D, this.zCoord + 0.5D); Vec3 v2 = Vec3.createVectorHelper(tx + 0.5D, ty + 0.5D, tz + 0.5D); MovingObjectPosition mop = ThaumcraftApiHelper.rayTraceIgnoringSource(this.worldObj, v1, v2, true, false, false); if ((mop != null) && (getDistanceFrom(mop.blockX, mop.blockY, mop.blockZ) < 16.0D)) { tx = mop.blockX; ty = mop.blockY; tz = mop.blockZ; Block bi = this.worldObj.getBlock(tx, ty, tz); int md = this.worldObj.getBlockMetadata(tx, ty, tz); if (!bi.isAir(this.worldObj, tx, ty, tz)) { Thaumcraft.proxy.hungryNodeFX(this.worldObj, tx, ty, tz, this.xCoord, this.yCoord + 1, this.zCoord, bi, md); } } } }
Example 4
Source File: OilGeneratorFix.java From NewHorizonsCoreMod with GNU General Public License v3.0 | 5 votes |
private void generateOil( World world, Random rand, int xx, int zz, boolean testFirst ) { Vec3 pos = Vec3.createVectorHelper( 0, 0, 0 ); if( shouldSpawnOil( world, rand, xx, zz, pos ) ) { int x = (int) pos.xCoord; int cy = (int) pos.yCoord; int z = (int) pos.zCoord; int tMinRadius = MainRegistry.CoreConfig.OilFixConfig.OilSphereMinRadius; int tMaxRadius = MainRegistry.CoreConfig.OilFixConfig.OilSphereMaxSize; int r = rand.nextInt(tMaxRadius + 1 - tMinRadius) + tMinRadius; if( testFirst && checkOilPresent( world, x, cy, z, r )) { return; } if( YAMCore.isDebug() ) { _mLog.info(String.format("About to generate OilSphere, centered at %d/%d/%d, radius %d", x, cy, z, r)); } // Taken from BuildCraft; Dont' generate if topblock is at y = 5 // Should already be covered in shouldSpawnOil, but you never know.. int groundLevel = getTopBlock( world, x, z ); if( groundLevel < 5 ) { if( YAMCore.isDebug() ) { _mLog.warn("OilGenerator stopped; World-height is below 5"); } return; } buildOilStructure( world, rand, x, cy, z, r, groundLevel, _mBuildCraftOilBlock, true ); } }
Example 5
Source File: RenderBlockTarget.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
private boolean isPlayerLookingAtTarget(){ Vec3 vec3 = player.getLook(1.0F).normalize(); Vec3 vec31 = Vec3.createVectorHelper(blockX + 0.5D - player.posX, blockY + 0.5D - player.posY + player.getEyeHeight(), blockZ + 0.5D - player.posZ); double d0 = vec31.lengthVector(); vec31 = vec31.normalize(); double d1 = vec3.dotProduct(vec31); return d1 > 1.0D - 0.025D / d0; }
Example 6
Source File: TCMazeHandler.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private static void setupSession(EntityPlayer player, WorldServer world) { Vec3 currentPos = Vec3.createVectorHelper(player.posX, player.posY, player.posZ); int originDim = player.worldObj.provider.dimensionId; Map<CellLoc, Short> locs = calculateCellLocs(world); MazeBuilderThread t = new MazeBuilderThread((EntityPlayerMP) player, locs, originDim, currentPos); t.start(); }
Example 7
Source File: EntityParachute.java From archimedes-ships with MIT License | 5 votes |
public EntityParachute(World world, EntityShip ship, int x, int y, int z) { this(world); Vec3 vec = Vec3.createVectorHelper(x - ship.getShipChunk().getCenterX(), y - ship.getShipChunk().minY(), z - ship.getShipChunk().getCenterZ()); vec.rotateAroundY((float) Math.toRadians(ship.rotationYaw)); setLocationAndAngles(ship.posX + vec.xCoord, ship.posY + vec.yCoord - 2D, ship.posZ + vec.zCoord, 0F, 0F); motionX = ship.motionX; motionY = ship.motionY; motionZ = ship.motionZ; }
Example 8
Source File: TileNodeManipulator.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
private Vec3 getRelPedestalLoc(int pedestalId) { try { ChunkCoordinates cc = bufferedCCPedestals.get(pedestalId); return Vec3.createVectorHelper(xCoord - cc.posX, yCoord - cc.posY, zCoord - cc.posZ); } catch (Exception exc) {} return Vec3.createVectorHelper(0, 0, 0); }
Example 9
Source File: PlaceTraps.java From Artifacts with MIT License | 5 votes |
private void pyramidArrowTrap(Random rand, World world, int x, int y, int z) { for(int ox = -1; ox <= 1; ox++) { for(int oz = -1; oz <= 1; oz++) { world.setBlock(x+ox, 51, z+oz, Blocks.sandstone); } } for(int ox = -1; ox <= 1; ox++) { for(int oz = -1; oz <= 1; oz++) { Vec3 v = Vec3.createVectorHelper(x+ox, 52, z+oz); simpleTrap(rand, world, v); } } }
Example 10
Source File: ArmourStandInteractMessage.java From Et-Futurum with The Unlicense | 5 votes |
public ArmourStandInteractMessage(int dimID, EntityArmourStand stand, EntityPlayer player) { this.dimID = dimID; standID = stand.getEntityId(); playerID = player.getEntityId(); MovingObjectPosition hit = Minecraft.getMinecraft().objectMouseOver; hitPos = Vec3.createVectorHelper(hit.hitVec.xCoord - stand.posX, hit.hitVec.yCoord - stand.posY, hit.hitVec.zCoord - stand.posZ); }
Example 11
Source File: ArmourStandInteractMessage.java From Et-Futurum with The Unlicense | 5 votes |
@Override public void fromBytes(ByteBuf buf) { dimID = buf.readInt(); standID = buf.readInt(); playerID = buf.readInt(); hitPos = Vec3.createVectorHelper(buf.readDouble(), buf.readDouble(), buf.readDouble()); }
Example 12
Source File: PneumaticCraftUtils.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static Pair<Vec3, Vec3> getStartAndEndLookVec(EntityLivingBase entity, float maxDistance){ Vec3 entityVec; if(entity.worldObj.isRemote && entity instanceof EntityPlayer) { entityVec = Vec3.createVectorHelper(entity.posX, entity.posY + 1.6200000000000001D - entity.yOffset, entity.posZ); } else { entityVec = Vec3.createVectorHelper(entity.posX, entity.posY + entity.getEyeHeight() - entity.yOffset - (entity.isSneaking() ? 0.08 : 0), entity.posZ); } Vec3 entityLookVec = entity.getLook(1.0F); Vec3 maxDistVec = entityVec.addVector(entityLookVec.xCoord * maxDistance, entityLookVec.yCoord * maxDistance, entityLookVec.zCoord * maxDistance); return new ImmutablePair(entityVec, maxDistVec); }
Example 13
Source File: EntityShip.java From archimedes-ships with MIT License | 5 votes |
public void driftToGrid() { if( Math.abs( motionYaw ) < BASE_TURN_SPEED * 0.25f ) { float targetYaw = Math.round(rotationYaw / 90F) * 90F - rotationYaw; float targetDir = Math.min( Math.abs( targetYaw ), BASE_TURN_SPEED * 0.25f ) * Math.signum( targetYaw ); motionYaw = targetDir; } if( Math.abs( motionX ) < BASE_FORWARD_SPEED * 0.25f && Math.abs( motionZ ) < BASE_FORWARD_SPEED * 0.25f ) { Vec3 size = Vec3.createVectorHelper(shipChunk.getSizeX(), shipChunk.getSizeY(), shipChunk.getSizeZ()); size.rotateAroundY((float) Math.toRadians(rotationYaw)); Vec3 target = Vec3.createVectorHelper(getBlockAt(posX, size.xCoord), getBlockAt(posY, size.yCoord), getBlockAt(posZ, size.zCoord)); double ix = target.xCoord - posX; double iy = target.yCoord - posY; double iz = target.zCoord - posZ; double targetX = Math.min( Math.abs( ix ), BASE_FORWARD_SPEED * 0.25f ) * Math.signum( ix ); double targetY = Math.min( Math.abs( iy ), BASE_FORWARD_SPEED * 0.25f ) * Math.signum( iy ); double targetZ = Math.min( Math.abs( iz ), BASE_FORWARD_SPEED * 0.25f ) * Math.signum( iz ); motionX = targetX; motionZ = targetZ; } }
Example 14
Source File: EntityDrone.java From PneumaticCraft with GNU General Public License v3.0 | 4 votes |
@Override public Vec3 getPosition(){ return Vec3.createVectorHelper(posX, posY, posZ); }
Example 15
Source File: PlaceTraps.java From Artifacts with MIT License | 4 votes |
private boolean forwardTrap(Random rand, World world, Vec3[] c) { Vec3 pos = Vec3.createVectorHelper(c[0].xCoord, c[0].yCoord, c[0].zCoord); world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord), MathHelper.floor_double(pos.zCoord+1), BlockTrap.instance, 0, 3); int m = 0; if(c[1].xCoord == 0) { if(c[1].zCoord == 1) { m = 3; } else { m = 2; } } else { if(c[1].xCoord == 1) { m = 5; } else { m = 4; } } world.setBlockMetadataWithNotify(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord+1), MathHelper.floor_double(pos.zCoord), m, 3); TileEntityTrap dis = (TileEntityTrap)world.getTileEntity(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord+1), MathHelper.floor_double(pos.zCoord)); if(dis != null) { addTrapItem(rand, dis); } else { TileEntityDispenser dis2 = (TileEntityDispenser)world.getTileEntity(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord+1), MathHelper.floor_double(pos.zCoord)); if(dis2 != null) { addTrapItem(rand, dis); } } world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord), MathHelper.floor_double(pos.zCoord), Blocks.unlit_redstone_torch, 5, 3); pos.xCoord += c[1].xCoord; pos.zCoord += c[1].zCoord; world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord-1), MathHelper.floor_double(pos.zCoord), Blocks.redstone_wire, 15, 3); pos.xCoord += c[1].xCoord; pos.zCoord += c[1].zCoord; world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord-1), MathHelper.floor_double(pos.zCoord), Blocks.air, 0, 3); world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord-2), MathHelper.floor_double(pos.zCoord), Blocks.redstone_wire, 14, 3); pos.xCoord += c[1].xCoord; pos.zCoord += c[1].zCoord; m = 0; if(c[1].xCoord == 0) { if(c[1].zCoord == 1) { m = 3; } else { m = 4; } } else { if(c[1].xCoord == 1) { m = 1; } else { m = 2; } } world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord-2), MathHelper.floor_double(pos.zCoord), Blocks.redstone_torch, m, 3); pos.xCoord += c[1].xCoord; pos.zCoord += c[1].zCoord; world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord-1), MathHelper.floor_double(pos.zCoord), Blocks.redstone_wire, 0, 3); world.setBlock(MathHelper.floor_double(pos.xCoord), MathHelper.floor_double(pos.yCoord+1), MathHelper.floor_double(pos.zCoord), BlockArtifactsPressurePlate.invisObsidian, 0, 3); return true; }
Example 16
Source File: PlaceTraps.java From Artifacts with MIT License | 4 votes |
private boolean sideTrapB(World world, Vec3[] c) { Vec3 pos = Vec3.createVectorHelper(c[0].xCoord, c[0].yCoord, c[0].zCoord); pos.xCoord += c[1].xCoord*4; pos.zCoord += c[1].zCoord*4; return false; }
Example 17
Source File: PlaceTraps.java From Artifacts with MIT License | 4 votes |
private Vec3[] locateStrongholdCorridor(World world, int x, int y, int z) { if(world.getBlock(x, y+1, z) == Blocks.air) { if(world.getBlock(x+1, y+1, z) == Blocks.air && world.getBlock(x-1, y+1, z) == Blocks.air && world.getBlock(x, y+1, z+1) == Blocks.air && world.getBlock(x, y+1, z-1) == Blocks.air) { if(world.getBlock(x+1, y+1, z+1) == Blocks.air && world.getBlock(x+1, y+1, z-1) == Blocks.air && world.getBlock(x-1, y+1, z+1) == Blocks.air && world.getBlock(x-1, y+1, z-1) == Blocks.air) { return new Vec3[]{Vec3.createVectorHelper(x, y, z),Vec3.createVectorHelper(0, 0, 0)}; } else { if(world.getBlock(x+1, y+1, z+1) == Blocks.stonebrick) { return locateStrongholdCorridor(world,x+1, y+1, z+1); } else if(world.getBlock(x+1, y+1, z-1) == Blocks.stonebrick) { return locateStrongholdCorridor(world,x+1, y+1, z-1); } else if(world.getBlock(x-1, y+1, z+1) == Blocks.stonebrick) { return locateStrongholdCorridor(world,x-1, y+1, z+1); } else if(world.getBlock(x-1, y+1, z-1) == Blocks.stonebrick) { return locateStrongholdCorridor(world,x-1, y+1, z-1); } } } else if(world.getBlock(x+1, y+1, z) == Blocks.air && world.getBlock(x, y+1, z+1) == Blocks.air && world.getBlock(x+2, y+1, z) == Blocks.air && world.getBlock(x, y+1, z+2) == Blocks.air && world.getBlock(x+1, y+1, z+1) == Blocks.air) { return new Vec3[]{Vec3.createVectorHelper(x+1, y, z+1),Vec3.createVectorHelper(-1, 0, -1)}; } else if(world.getBlock(x-1, y+1, z) == Blocks.air && world.getBlock(x, y+1, z+1) == Blocks.air && world.getBlock(x-2, y+1, z) == Blocks.air && world.getBlock(x, y+1, z+2) == Blocks.air && world.getBlock(x-1, y+1, z+1) == Blocks.air) { return new Vec3[]{Vec3.createVectorHelper(x-1, y, z+1),Vec3.createVectorHelper(1, 0, -1)}; } else if(world.getBlock(x+1, y+1, z) == Blocks.air && world.getBlock(x, y+1, z-1) == Blocks.air && world.getBlock(x+2, y+1, z) == Blocks.air && world.getBlock(x, y+1, z-2) == Blocks.air && world.getBlock(x+1, y+1, z-1) == Blocks.air) { return new Vec3[]{Vec3.createVectorHelper(x+1, y, z-1),Vec3.createVectorHelper(-1, 0, 1)}; } else if(world.getBlock(x-1, y+1, z) == Blocks.air && world.getBlock(x, y+1, z-1) == Blocks.air && world.getBlock(x-2, y+1, z) == Blocks.air && world.getBlock(x, y+1, z-2) == Blocks.air && world.getBlock(x-1, y+1, z-1) == Blocks.air) { return new Vec3[]{Vec3.createVectorHelper(x-1, y, z-1),Vec3.createVectorHelper(-1, 0, -1)}; } } else if(world.getBlock(x, y+1, z) == Blocks.stonebrick) { y++; if(world.getBlock(x+1, y, z) == Blocks.air) { return locateStrongholdCorridor(world, x+1, y-1, z); } else if(world.getBlock(x-1, y, z) == Blocks.air) { return locateStrongholdCorridor(world, x-1, y-1, z); } else if(world.getBlock(x, y, z+1) == Blocks.air) { return locateStrongholdCorridor(world, x, y-1, z+1); } else if(world.getBlock(x, y, z-1) == Blocks.air) { return locateStrongholdCorridor(world, x, y-1, z-1); } else { if(world.getBlock(x+1, y, z+1) == Blocks.air) { return locateStrongholdCorridor(world, x+1, y-1, z+1); } else if(world.getBlock(x-1, y, z+1) == Blocks.air) { return locateStrongholdCorridor(world, x-1, y-1, z+1); } else if(world.getBlock(x-1, y, z-1) == Blocks.air) { return locateStrongholdCorridor(world, x-1, y-1, z-1); } else if(world.getBlock(x+1, y, z-1) == Blocks.air) { return locateStrongholdCorridor(world, x+1, y-1, z-1); } } } return null; }
Example 18
Source File: EntityRabbit.java From Et-Futurum with The Unlicense | 4 votes |
@Override public void updateAITasks() { super.updateAITasks(); if (getMoveHelper().getSpeed() > 0.8D) setMoveType(EntityRabbit.EnumMoveType.SPRINT); else if (moveType != EntityRabbit.EnumMoveType.ATTACK) setMoveType(EntityRabbit.EnumMoveType.HOP); if (currentMoveTypeDuration > 0) currentMoveTypeDuration--; if (carrotTicks > 0) { carrotTicks -= rand.nextInt(3); if (carrotTicks < 0) carrotTicks = 0; } if (onGround) { if (!field_175537_bp) { setJumping(false, EntityRabbit.EnumMoveType.NONE); func_175517_cu(); } EntityRabbit.RabbitJumpHelper rabbitjumphelper = getJumpHelper(); if (!rabbitjumphelper.getIsJumping()) { if (!getNavigator().noPath() && currentMoveTypeDuration == 0) { PathEntity pathentity = getNavigator().getPath(); Vec3 vec3 = Vec3.createVectorHelper(getMoveHelper().getX(), getMoveHelper().getY(), getMoveHelper().getZ()); if (pathentity != null && pathentity.getCurrentPathIndex() < pathentity.getCurrentPathLength()) vec3 = pathentity.getPosition(this); calculateRotationYaw(vec3.xCoord, vec3.zCoord); doMovementAction(moveType); } } else if (!rabbitjumphelper.func_180065_d()) func_175518_cr(); } field_175537_bp = onGround; }
Example 19
Source File: EntityShip.java From archimedes-ships with MIT License | 4 votes |
public void updateRiderPosition(Entity entity, int seatx, int seaty, int seatz, int flags) { if (entity != null) { float yaw = (float) Math.toRadians(rotationYaw); float pitch = (float) Math.toRadians(rotationPitch); int x1 = seatx, y1 = seaty, z1 = seatz; if ((flags & 1) == 1) { if (frontDirection == 0) { z1 -= 1; } else if (frontDirection == 1) { x1 += 1; } else if (frontDirection == 2) { z1 += 1; } else if (frontDirection == 3) { x1 -= 1; } Block block = shipChunk.getBlock(x1, MathHelper.floor_double(y1 + getMountedYOffset() + entity.getYOffset()), z1); if (block.isOpaqueCube()) { x1 = seatx; y1 = seaty; z1 = seatz; } } double yoff = (flags & 2) == 2 ? 0d : getMountedYOffset(); Vec3 vec = Vec3.createVectorHelper(x1 - shipChunk.getCenterX() + 0.5d, y1 - shipChunk.minY() + yoff, z1 - shipChunk.getCenterZ() + 0.5d); switch (frontDirection) { case 0: vec.rotateAroundZ(-pitch); break; case 1: vec.rotateAroundX(pitch); break; case 2: vec.rotateAroundZ(pitch); break; case 3: vec.rotateAroundX(-pitch); break; } vec.rotateAroundY(yaw); entity.setPosition(posX + vec.xCoord, posY + vec.yCoord + entity.getYOffset(), posZ + vec.zCoord); } }
Example 20
Source File: AMVector3.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 4 votes |
public Vec3 toVec3D() { return Vec3.createVectorHelper(this.x, this.y, this.z); }