net.minecraft.util.Vec3 Java Examples

The following examples show how to use net.minecraft.util.Vec3. 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: WirelessBolt.java    From WirelessRedstone with MIT License 6 votes vote down vote up
private void vecBBDamageSegment(Vector3 start, Vector3 end, ArrayList<Entity> entitylist) {
    Vec3 start3D = start.toVec3D();
    Vec3 end3D = end.toVec3D();

    for (Iterator<Entity> iterator = entitylist.iterator(); iterator.hasNext(); ) {
        Entity entity = iterator.next();
        if (entity instanceof EntityLivingBase &&
                (entity.boundingBox.isVecInside(start3D) || entity.boundingBox.isVecInside(end3D))) {
            if (entity instanceof EntityPlayer)
                entity.attackEntityFrom(WirelessRedstoneCore.damagebolt, playerdamage);
            else
                entity.attackEntityFrom(WirelessRedstoneCore.damagebolt, entitydamage);

            ether.jamEntity((EntityLivingBase) entity, true);
        }
    }
}
 
Example #2
Source File: AdapterSensor.java    From OpenPeripheral-Addons with MIT License 6 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get a table of information about the surrounding area. Includes map color and whether each block is UNKNOWN, AIR, LIQUID, or SOLID.")
public List<Map<String, Object>> sonicScan(ISensorEnvironment env) {
	int range = 1 + env.getSensorRange() / 2;
	List<Map<String, Object>> results = Lists.newArrayList();
	Vec3 sensorPos = env.getLocation();
	int sx = MathHelper.floor_double(sensorPos.xCoord);
	int sy = MathHelper.floor_double(sensorPos.yCoord);
	int sz = MathHelper.floor_double(sensorPos.zCoord);

	final World world = env.getWorld();

	final int rangeSq = range * range;

	for (int dx = -range; dx <= range; dx++) {
		for (int dy = -range; dy <= range; dy++) {
			for (int dz = -range; dz <= range; dz++) {
				if (checkRange(dx, dy, dz, rangeSq)) {
					Map<String, Object> result = describeBlock(world, sx, sy, sz, dx, dy, dz);
					if (result != null) results.add(result);
				}
			}
		}
	}

	return results;
}
 
Example #3
Source File: DroneEntityAIPickupItems.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Returns whether an in-progress EntityAIBase should continue executing
 */
@Override
public boolean continueExecuting(){
    if(curPickingUpEntity.isDead) return false;
    if(Vec3.createVectorHelper(curPickingUpEntity.posX, curPickingUpEntity.posY, curPickingUpEntity.posZ).distanceTo(drone.getPosition()) < 1.5) {
        ItemStack stack = curPickingUpEntity.getEntityItem();
        if(itemPickupWidget.isItemValidForFilters(stack)) {
            new EventHandlerPneumaticCraft().onPlayerPickup(new EntityItemPickupEvent(drone.getFakePlayer(), curPickingUpEntity));//not posting the event globally, as I don't have a way of handling a canceled event.
            int stackSize = stack.stackSize;
            ItemStack remainder = PneumaticCraftUtils.exportStackToInventory(drone.getInventory(), stack, ForgeDirection.UP);//side doesn't matter, drones aren't ISided.
            if(remainder == null) {
                drone.onItemPickupEvent(curPickingUpEntity, stackSize);
                curPickingUpEntity.setDead();
            }
        }
        return false;
    }
    return !drone.getPathNavigator().hasNoPath();
}
 
Example #4
Source File: PlaceTraps.java    From Artifacts with MIT License 6 votes vote down vote up
private boolean coveredSpikedPit(Random rand, World world, Vec3 c, Block blockID, int meta) {
	if(meta < 0) {
		meta = rand.nextInt(-1 * meta);
	}
	for(int i=-2; i<=2; i++) {
		for(int j=-2; j<=2; j++) {
			if(i > -2 && i < 2 && j > -2 && j < 2) {
				world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord), MathHelper.floor_double(c.zCoord+j), BlockIllusionary.instance, 0, 3);
				world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-1), MathHelper.floor_double(c.zCoord+j), Blocks.air, 0, 3);
				world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-2), MathHelper.floor_double(c.zCoord+j), Blocks.air, 0, 3);
				world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-3), MathHelper.floor_double(c.zCoord+j), BlockSpikes.instance, 0, 3);
				world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-4), MathHelper.floor_double(c.zCoord+j), blockID, meta, 3);
			}
			else {
				if(world.getBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-1), MathHelper.floor_double(c.zCoord+j)).isOpaqueCube())
					world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-1), MathHelper.floor_double(c.zCoord+j), blockID, meta, 3);
				if(world.getBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-2), MathHelper.floor_double(c.zCoord+j)).isOpaqueCube())
					world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-2), MathHelper.floor_double(c.zCoord+j), blockID, meta, 3);
				if(world.getBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-3), MathHelper.floor_double(c.zCoord+j)).isOpaqueCube())
					world.setBlock(MathHelper.floor_double(c.xCoord+i), MathHelper.floor_double(c.yCoord-3), MathHelper.floor_double(c.zCoord+j), blockID, meta, 3);
			}
		}
	}
	return true;
}
 
Example #5
Source File: NPCUtils.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * Checks if a given entity is near any NPC with the given {@link Tag}s.
 *
 * @param entity the entity to check
 * @return {@code true} if the entity is near an NPC with the given tags, {@code false} otherwise
 */
public static boolean isNearAnyNPCWithTags(Entity entity, Set<Tag> tags) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    Location currentLocation = main.getUtils().getLocation();

    for (NPC npc:
            NPC_LIST) {
        if (npc.hasLocation(currentLocation)) {
            Vec3 NPCVector = new Vec3(npc.getX(), npc.getY(), npc.getZ());
            Vec3 entityVector = entity.getPositionVector();

            if (NPCVector.distanceTo(entityVector) <= HIDE_RADIUS) {
                if (npc.getTags().containsAll(tags))
                    return true;
            }
        }
    }
    return false;
}
 
Example #6
Source File: NPCUtils.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * Checks if a given entity is near the NPC with the given name.
 *
 * @param entity the entity to check
 * @param NPCName the NPC's name in {@link NPC}
 * @return {@code true} if the entity is near the matching NPC,{@code false} if the entity is not near the matching NPC or no matching NPC is found
 */
public static boolean isNearNPC(Entity entity, String NPCName) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    Location currentLocation = main.getUtils().getLocation();

    for (NPC npc:
         NPC_LIST) {
        if (npc.name().equals(NPCName) && npc.hasLocation(currentLocation)) {
            Vec3 NPCVector = new Vec3(npc.getX(), npc.getY(), npc.getZ());
            Vec3 entityVector = entity.getPositionVector();

            if (NPCVector.distanceTo(entityVector) <= HIDE_RADIUS) {
                return true;
            }
        }
    }
    return false;
}
 
Example #7
Source File: ServerEventHandler.java    From Et-Futurum with The Unlicense 6 votes vote down vote up
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
	if (!EtFuturum.enableDmgIndicator)
		return;
	int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
	if (amount <= 0)
		return;

	// If the attacker is a player spawn the hearts aligned and facing it
	if (event.source instanceof EntityDamageSource) {
		EntityDamageSource src = (EntityDamageSource) event.source;
		Entity attacker = src.getSourceOfDamage();
		if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
			EntityPlayer player = (EntityPlayer) attacker;
			Vec3 look = player.getLookVec();
			look.rotateAroundY((float) Math.PI / 2);
			for (int i = 0; i < amount; i++) {
				double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
				double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
				double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
				EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
			}
		}
	}
}
 
Example #8
Source File: NPCUtils.java    From SkyblockAddons with MIT License 6 votes vote down vote up
/**
 * Checks if a given entity is near any NPC with the given {@link Tag}.
 *
 * @param entity the entity to check
 * @return {@code true} if the entity is near an NPC, {@code false} otherwise
 */
public static boolean isNearAnyNPCWithTag(Entity entity, Tag tag) {
    SkyblockAddons main = SkyblockAddons.getInstance();
    Location currentLocation = main.getUtils().getLocation();

    for (NPC npc:
            NPC_LIST) {
        if (npc.hasLocation(currentLocation)) {
            Vec3 NPCVector = new Vec3(npc.getX(), npc.getY(), npc.getZ());
            Vec3 entityVector = entity.getPositionVector();

            if (NPCVector.distanceTo(entityVector) <= HIDE_RADIUS) {
                if (npc.hasTag(tag))
                    return true;
            }
        }
    }
    return false;
}
 
Example #9
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
private void manipulationTick() {
    workTick++;
    if(workTick < 300) {
        if(workTick % 16 == 0) {
            PacketStartAnimation packet = new PacketStartAnimation(PacketStartAnimation.ID_RUNES, xCoord, yCoord, zCoord);
            PacketHandler.INSTANCE.sendToAllAround(packet, getTargetPoint(32));
        }
        if(worldObj.rand.nextInt(4) == 0) {
            Vec3 rel = getRelPillarLoc(worldObj.rand.nextInt(4));
            PacketTCNodeBolt bolt = new PacketTCNodeBolt(xCoord + 0.5F, yCoord + 2.5F, zCoord + 0.5F, (float) (xCoord + 0.5F + rel.xCoord), (float) (yCoord + 2.5F + rel.yCoord), (float) (zCoord + 0.5F + rel.zCoord), 0, false);
            PacketHandler.INSTANCE.sendToAllAround(bolt, getTargetPoint(32));
        }
    } else {
        scheduleManipulation();
    }
}
 
Example #10
Source File: TileEntityQBlock.java    From qcraft-mod with Apache License 2.0 6 votes vote down vote up
private boolean checkRayClear( Vec3 playerPos, Vec3 blockPos )
{
    MovingObjectPosition position = worldObj.rayTraceBlocks( playerPos, blockPos );
    if( position == null )
    {
        return true;
    }
    else if( position.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK )
    {
        if( position.blockX == xCoord &&
                position.blockY == yCoord &&
                position.blockZ == zCoord )
        {
            return true;
        }
    }
    return false;
}
 
Example #11
Source File: TileEssentiaCompressor.java    From Gadomancy with GNU Lesser General Public License v3.0 6 votes vote down vote up
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 #12
Source File: EntityMetadataBuilder.java    From OpenPeripheral with MIT License 6 votes vote down vote up
private static Map<String, Object> createBasicProperties(Entity entity, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();
	addPositionInfo(map, entity, relativePos);
	map.put("name", entity.getCommandSenderName());
	map.put("id", entity.getEntityId());
	map.put("uuid", entity.getUniqueID());

	if (entity.riddenByEntity != null) {
		map.put("riddenBy", entity.riddenByEntity.getEntityId());
	}

	if (entity.ridingEntity != null) {
		map.put("ridingEntity", entity.ridingEntity.getEntityId());
	}
	return map;
}
 
Example #13
Source File: General.java    From Chisel-2 with GNU General Public License v2.0 6 votes vote down vote up
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3) {
	float var4 = 1.0F;
	float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
	float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
	double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
	double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
	double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
	// TODO- 1.7.10 fix?
	Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
	float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
	float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
	float var16 = -MathHelper.cos(-var5 * 0.017453292F);
	float var17 = MathHelper.sin(-var5 * 0.017453292F);
	float var18 = var15 * var16;
	float var20 = var14 * var16;
	double var21 = 5.0D;

	if (par2EntityPlayer instanceof EntityPlayerMP) {
		var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
	}

	Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
	return par1World.rayTraceBlocks(var13, var23, par3);
}
 
Example #14
Source File: PartFrame.java    From Framez with GNU General Public License v3.0 6 votes vote down vote up
@Override
public ExtendedMOP collisionRayTrace(Vec3 start, Vec3 end) {

    ExtendedMOP mop = super.collisionRayTrace(start, end);

    double d = 0.001;

    if (mop != null) {
        if (mop.hitVec.xCoord % 1 == 0)
            mop.hitVec.xCoord += ForgeDirection.getOrientation(mop.sideHit).offsetX * d;
        if (mop.hitVec.yCoord % 1 == 0)
            mop.hitVec.yCoord += ForgeDirection.getOrientation(mop.sideHit).offsetY * d;
        if (mop.hitVec.zCoord % 1 == 0)
            mop.hitVec.zCoord += ForgeDirection.getOrientation(mop.sideHit).offsetZ * d;

        // mop.blockX = (int) Math.floor(mop.hitVec.xCoord);
        // mop.blockY = (int) Math.floor(mop.hitVec.yCoord);
        // mop.blockZ = (int) Math.floor(mop.hitVec.zCoord);
    }

    return mop;
}
 
Example #15
Source File: AdapterSensor.java    From OpenPeripheral-Addons with MIT License 6 votes vote down vote up
@ScriptCallable(returnTypes = ReturnType.TABLE, description = "Get a table of information about a single block in the surrounding area. Includes map color and whether each block is UNKNOWN, AIR, LIQUID, or SOLID.")
public Map<String, Object> sonicScanTarget(ISensorEnvironment env,
		@Arg(name = "xOffset", description = "The target's offset from the sensor on the X-Axis.") int dx,
		@Arg(name = "yOffset", description = "The target's offset from the sensor on the Y-Axis.") int dy,
		@Arg(name = "zOffset", description = "The target's offset from the sensor on the Z-Axis.") int dz) {
	int range = 1 + env.getSensorRange() / 2;
	int rangeSq = range * range;
	if (checkRange(dx, dy, dz, rangeSq)) return null;

	Vec3 sensorPos = env.getLocation();
	int sx = MathHelper.floor_double(sensorPos.xCoord);
	int sy = MathHelper.floor_double(sensorPos.yCoord);
	int sz = MathHelper.floor_double(sensorPos.zCoord);

	return describeBlock(env.getWorld(), sx, sy, sz, dx, dy, dz);
}
 
Example #16
Source File: LanternRenderer.java    From GardenCollection with MIT License 6 votes vote down vote up
private void renderChain (IBlockAccess world, RenderBlocks renderer, BlockLantern block, int x, int y, int z) {
    Block lowerBlock = world.getBlock(x, y - 1, z);
    if (lowerBlock.isSideSolid(world, x, y - 1, z, ForgeDirection.UP))
        return;

    Block upperBlock = world.getBlock(x, y + 1, z);
    if (upperBlock instanceof IChainSingleAttachable) {
        Vec3 attach = ((IChainSingleAttachable) upperBlock).getChainAttachPoint(world, x, y + 1, z, 0);
        if (attach != null && attach != defaultAttachPoint) {
            RenderHelper.instance.setRenderBounds(0, 0, 0, 1, attach.yCoord, 1);
            RenderHelper.instance.renderCrossedSquares(world, ModBlocks.heavyChain, x, y + 1, z, ModBlocks.lightChain.getIcon(0, 4));
            return;
        }
    }

    IAttachable attachable = GardenAPI.instance().registries().attachable().getAttachable(upperBlock, world.getBlockMetadata(x, y + 1, z));
    if (attachable != null && attachable.isAttachable(world, x, y + 1, z, 0)) {
        double depth = attachable.getAttachDepth(world, x, y + 1, z, 0);
        if (depth > 0) {
            RenderHelper.instance.setRenderBounds(0, 0, 0, 1, depth, 1);
            RenderHelper.instance.renderCrossedSquares(world, ModBlocks.heavyChain, x, y + 1, z, ModBlocks.lightChain.getIcon(0, 4));
        }
    }
}
 
Example #17
Source File: General.java    From Chisel with GNU General Public License v2.0 6 votes vote down vote up
public static MovingObjectPosition getMovingObjectPositionFromPlayer(World par1World, EntityPlayer par2EntityPlayer, boolean par3)
{
    float var4 = 1.0F;
    float var5 = par2EntityPlayer.prevRotationPitch + (par2EntityPlayer.rotationPitch - par2EntityPlayer.prevRotationPitch) * var4;
    float var6 = par2EntityPlayer.prevRotationYaw + (par2EntityPlayer.rotationYaw - par2EntityPlayer.prevRotationYaw) * var4;
    double var7 = par2EntityPlayer.prevPosX + (par2EntityPlayer.posX - par2EntityPlayer.prevPosX) * var4;
    double var9 = par2EntityPlayer.prevPosY + (par2EntityPlayer.posY - par2EntityPlayer.prevPosY) * var4 + 1.62D - par2EntityPlayer.yOffset;
    double var11 = par2EntityPlayer.prevPosZ + (par2EntityPlayer.posZ - par2EntityPlayer.prevPosZ) * var4;
    //TODO- 1.7.10 fix?
    Vec3 var13 = Vec3.createVectorHelper(var7, var9, var11);
    float var14 = MathHelper.cos(-var6 * 0.017453292F - (float) Math.PI);
    float var15 = MathHelper.sin(-var6 * 0.017453292F - (float) Math.PI);
    float var16 = -MathHelper.cos(-var5 * 0.017453292F);
    float var17 = MathHelper.sin(-var5 * 0.017453292F);
    float var18 = var15 * var16;
    float var20 = var14 * var16;
    double var21 = 5.0D;

    if(par2EntityPlayer instanceof EntityPlayerMP)
    {
        var21 = ((EntityPlayerMP) par2EntityPlayer).theItemInWorldManager.getBlockReachDistance();
    }

    Vec3 var23 = var13.addVector(var18 * var21, var17 * var21, var20 * var21);
    return par1World.rayTraceBlocks(var13, var23, par3);
}
 
Example #18
Source File: VortexOfDoomAnimation.java    From Hyperium with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public List<Vec3> render(EntityPlayer player, double x, double y, double z) {
    ArrayList<Vec3> vec3s = new ArrayList<>();
    Vec3 base = new Vec3(x, y + 1.7, z);
    double l = Math.abs(.5 - ((System.currentTimeMillis() % 10000D) / 10000D)) * 4;
    l = l <= 1 ? Math.pow(l, 2) / 2 : -(Math.pow(l - 2, 2) - 2) / 2;
    l *= 2;

    for (int i = 0; i < 40; i++) {
        double v = Math.PI / 40 * i * 2;

        for (int j = 0; j < 6; j++) {
            vec3s.add(base.addVector(MathHelper.sin((float) (v + l * j / 2.5D)), -.2 * j, MathHelper.cos((float) (v + l * j / 2.5D))));
        }
    }

    return vec3s;
}
 
Example #19
Source File: BlockPneumaticPlantBase.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
@Override
public MovingObjectPosition collisionRayTrace(World world, int x, int y, int z, Vec3 startVect, Vec3 endVect){
    Block b = world.getBlock((int)Math.floor(endVect.xCoord), (int)Math.floor(endVect.yCoord), (int)Math.floor(endVect.zCoord));
    if(b instanceof BlockPressureTube) return null; // AirGrate farming support; seeds won't get stuck in plants

    return super.collisionRayTrace(world, x, y, z, startVect, endVect);
}
 
Example #20
Source File: TileNodeManipulator.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 #21
Source File: EntityWolfMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityWolf target, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();

	map.put("isShaking", target.getWolfShaking());
	map.put("isAngry", target.isAngry());
	map.put("collarColor", ColorUtils.vanillaBlockToColor(target.getCollarColor()).bitmask);

	return map;
}
 
Example #22
Source File: EntityPigMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityPig target, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();

	map.put("isSaddled", target.getSaddled());

	return map;
}
 
Example #23
Source File: PlaceTraps.java    From Artifacts with MIT License 5 votes vote down vote up
private boolean generateLibraryTrap(Random rand, World world, int tex, int vary, int tez, ForgeDirection orientation) {
		boolean ret = false;
		
		//System.out.println("Generating Library Trap.");
		//if(rand.nextInt(4) == 0) {
			//ret = true;
			int r = rand.nextInt(2);
			Vec3[] vec = new Vec3[2];
			vec[0] = Vec3.createVectorHelper(tex, vary, tez);
			vec[1] = Vec3.createVectorHelper(orientation.offsetX, orientation.offsetY, orientation.offsetZ);
			int ox = 0;
			int oz = 0;
			switch(r) {
				case 0:
					ox = rand.nextInt(3)-1;
					oz = rand.nextInt(3)-1;
					vec[0].xCoord += ox;
					vec[0].zCoord += oz;
					ret = simpleTrap(rand, world, vec[0]);
					//System.out.println(" - Simple Trap.");
					break;
				case 1:
					ret = coveredSpikedPit(rand, world, vec[0], Blocks.cobblestone, 0);
					//System.out.println(" - Covered Spikes.");
					break;
//				case 2:
//					ret = forwardTrap(rand, world, vec);
//					break;
//				case 3:
//					ret = sideTrapA(world, vec);
//					break;
//				case 4:
//					ret = sideTrapB(world, vec);
//					break;
				default:
			//}
		}
		return ret;
	}
 
Example #24
Source File: DroneAIPlace.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private void setFakePlayerAccordingToDir(){
    EntityPlayer fakePlayer = drone.getFakePlayer();
    Vec3 pos = drone.getPosition();
    fakePlayer.posX = pos.xCoord;
    fakePlayer.posZ = pos.zCoord;
    switch(ProgWidgetPlace.getDirForSides(((ISidedWidget)widget).getSides())){
        case UP:
            fakePlayer.rotationPitch = -90;
            fakePlayer.posY = pos.yCoord - 10;//do this for PistonBase.determineDirection()
            return;
        case DOWN:
            fakePlayer.rotationPitch = 90;
            fakePlayer.posY = pos.yCoord + 10;//do this for PistonBase.determineDirection()
            return;
        case NORTH:
            fakePlayer.rotationYaw = 180;
            fakePlayer.posY = pos.yCoord;//do this for PistonBase.determineDirection()
            break;
        case EAST:
            fakePlayer.rotationYaw = 270;
            fakePlayer.posY = pos.yCoord;//do this for PistonBase.determineDirection()
            break;
        case SOUTH:
            fakePlayer.rotationYaw = 0;
            fakePlayer.posY = pos.yCoord;//do this for PistonBase.determineDirection()
            break;
        case WEST:
            fakePlayer.rotationYaw = 90;
            fakePlayer.posY = pos.yCoord;//do this for PistonBase.determineDirection()
            break;
    }
}
 
Example #25
Source File: TCMazeSession.java    From Gadomancy with GNU Lesser General Public License v3.0 5 votes vote down vote up
TCMazeSession(EntityPlayer owner, Map<CellLoc, Short> locations, int dim, Vec3 origin) {
    this.player = (EntityPlayerMP) owner;
    this.chunksAffected = locations;
    this.originDimId = dim;
    this.originLocation = origin;
    this.portalCell = findPortal();
}
 
Example #26
Source File: EntitySheepMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntitySheep target, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();

	map.put("sheepColor", target.getFleeceColor());
	map.put("isSheared", target.getSheared());

	return map;
}
 
Example #27
Source File: PaintingMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityPainting target, Vec3 relativePos) {
	Map<String, Object> result = Maps.newHashMap();
	result.put("title", target.art.title);
	result.put("width", target.art.sizeX / 16);
	result.put("height", target.art.sizeY / 16);
	return result;
}
 
Example #28
Source File: RayTracer.java    From CodeChickenLib with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static Vec3 getCorrectedHeadVec(EntityPlayer player) {
    Vector3 v = Vector3.fromEntity(player);
    if (player.worldObj.isRemote) {
        v.y += player.getEyeHeight() - player.getDefaultEyeHeight();//compatibility with eye height changing mods
    } else {
        v.y += player.getEyeHeight();
        if (player instanceof EntityPlayerMP && player.isSneaking())
            v.y -= 0.08;
    }
    return v.vec3();
}
 
Example #29
Source File: ItemFrameMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityItemFrame target, Vec3 relativePos) {
	Map<String, Object> result = Maps.newHashMap();

	result.put("item", target.getDisplayedItem());
	result.put("rotation", target.getRotation());

	return result;
}
 
Example #30
Source File: EntityCreeperMetaProvider.java    From OpenPeripheral-Integration with MIT License 5 votes vote down vote up
@Override
public Object getMeta(EntityCreeper target, Vec3 relativePos) {
	Map<String, Object> map = Maps.newHashMap();

	map.put("isCharged", target.getPowered());

	return map;
}