use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class TravelController method getScaleForCandidate.
public double getScaleForCandidate(@Nonnull Vector3d loc) {
if (!currentView.isValid()) {
return 1;
}
BlockPos bc = new BlockPos(loc.x, loc.y, loc.z);
float ratio = -1;
Float r = candidates.get(bc);
if (r != null) {
ratio = r;
}
if (ratio < 0) {
// no cached value
addRatio(bc);
ratio = candidates.get(bc);
}
// smoothly zoom to a larger size, starting when the point is the middle 20% of the screen
float start = 0.2f;
float end = 0.01f;
double mix = MathHelper.clamp((start - ratio) / (start - end), 0, 1);
double scale = 1;
if (mix > 0) {
Vector3d eyePoint = Util.getEyePositionEio(Minecraft.getMinecraft().player);
scale = tanFovRad * eyePoint.distance(loc);
// Using this scale will give us the block full screen, we will make it 20% of the screen
scale *= Config.travelAnchorZoomScale;
// only apply 70% of the scaling so more distance targets are still smaller than closer targets
float nf = 1 - MathHelper.clamp((float) eyePoint.distanceSquared(loc) / TravelSource.STAFF.getMaxDistanceTravelledSq(), 0, 1);
scale = scale * (0.3 + 0.7 * nf);
scale = (scale * mix) + (1 - mix);
scale = Math.max(1.01, scale);
}
return scale;
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class ItemRodOfReturn method onUsingClient.
@SideOnly(Side.CLIENT)
private void onUsingClient(ItemStack stack, EntityLivingBase player, int timeLeft) {
if (timeLeft > (Config.rodOfReturnTicksToActivate - 2)) {
return;
}
float progress = 1 - ((float) timeLeft / Config.rodOfReturnTicksToActivate);
float spinSpeed = progress * 2;
if (activeSound != null) {
activeSound.setPitch(MathHelper.clamp(0.5f + (spinSpeed / 1.5f), 0.5f, 2));
}
if (activeSound == null) {
BlockPos p = player.getPosition();
activeSound = new MachineSound(ACTIVE_RES, p.getX(), p.getY(), p.getZ(), 0.3f, 1);
playSound();
}
double dist = 2 - (progress * 1.5);
Random rand = player.world.rand;
for (int i = 0; i < 6; i++) {
double xo = randomOffset(rand, dist);
double yo = randomOffset(rand, dist);
double zo = randomOffset(rand, dist);
double x = player.posX + xo;
double y = player.posY + yo + player.height / 2;
double z = player.posZ + zo;
Vector3d velocity = new Vector3d(xo, yo, zo);
velocity.normalize();
Particle fx = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.PORTAL.getParticleID(), x, y, z, 0, 0, 0, 0);
if (fx != null) {
// if(rand.nextInt(8) == 0) {
// fx.setRBGColorF((rand.nextFloat() * 0.1f), 0.6f + (rand.nextFloat() * 0.15f), 0.75f + (rand.nextFloat() * 0.2f));
// }
ClientUtil.setParticleVelocity(fx, velocity.x, velocity.y, velocity.z);
fx.setMaxAge(timeLeft + 2);
}
}
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class ConnectionModeGeometry method addModeConnectorQuads.
public static void addModeConnectorQuads(EnumFacing dir, Offset offset, TextureAtlasSprite tex, Vector4f color, List<BakedQuad> quads) {
List<Vertex> verts = VERTS.get(dir);
if (verts == null) {
return;
}
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
List<Vertex> xFormed = new ArrayList<Vertex>(verts.size());
for (Vertex v : verts) {
Vertex xf = new Vertex(v);
xf.xyz.add(trans);
xFormed.add(xf);
}
BakedQuadBuilder.addBakedQuads(quads, xFormed, tex, color);
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class SoundDetector method onClientTick.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(TickEvent.ClientTickEvent event) {
if (!enabled) {
return;
}
List<SoundSource> sounds = new ArrayList<SoundSource>(MAX_PARTICLES);
soundQueue.drainTo(sounds);
try {
final Minecraft minecraft = Minecraft.getMinecraft();
Vector3d eye = Util.getEyePositionEio(minecraft.player);
for (SoundSource ss : sounds) {
double distSq = ss.pos.distanceSquared(eye);
int minDist = ss.isEntity ? 4 : 49;
if (distSq > minDist && distSq <= Config.darkSteelSoundLocatorRange * Config.darkSteelSoundLocatorRange) {
minecraft.effectRenderer.addEffect(new SoundParticle(minecraft.player.world, ss));
}
}
} catch (Exception ex) {
// Probably not necessary anymore but safety first!
}
}
use of com.enderio.core.common.vecmath.Vector3d in project EnderIO by SleepyTrousers.
the class ItemCoordSelector method printCoords.
private boolean printCoords(@Nonnull ItemStack stack, @Nonnull World world, @Nonnull EntityPlayer player) {
Vector3d headVec = Util.getEyePositionEio(player);
Vec3d start = headVec.getVec3();
Vec3d lookVec = player.getLook(1.0F);
double reach = 500;
headVec.add(lookVec.x * reach, lookVec.y * reach, lookVec.z * reach);
RayTraceResult mop = world.rayTraceBlocks(start, headVec.getVec3());
if (mop == null) {
return false;
}
BlockPos bc = BlockCoord.get(mop);
if (!player.isSneaking()) {
EnumFacing dir = mop.sideHit;
bc = bc.offset(dir);
}
return ModObject.itemLocationPrintout.openClientGui(world, bc, player, null, ItemLocationPrintout.GUI_ID_LOCATION_PRINTOUT_CREATE);
}
Aggregations