当前位置: 首页>>代码示例>>Java>>正文


Java Vec3d.scale方法代码示例

本文整理汇总了Java中net.minecraft.util.math.Vec3d.scale方法的典型用法代码示例。如果您正苦于以下问题:Java Vec3d.scale方法的具体用法?Java Vec3d.scale怎么用?Java Vec3d.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.util.math.Vec3d的用法示例。


在下文中一共展示了Vec3d.scale方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: FireBall

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public static Object FireBall(Object... args) {

        ScriptExecutor executor = (ScriptExecutor)args[0];

        Vec3d look = (Vec3d)executor.resolveInput((short)1);
        Double speed = (Double)executor.resolveInput((short)2);
        Vec3d initPos = (Vec3d)executor.resolveInput((short)3);
        Vec3d initPosRel = (Vec3d)executor.resolveInput((short)4);

        if (look == null) {
            look = executor.player.getLookVec();
        }
        if (speed == null) {
            speed = 0.1;
        }
        if (initPos == null) {
            if(initPosRel==null)
                initPos = executor.player.getPositionEyes(1.0F).add(executor.player.getLookVec().scale(2));
            else
                initPos = initPosRel.add(executor.player.getPositionVector());
        }

        look = look.scale(speed);

        EntityLargeFireball fireball = new EntityLargeSettableFireball(executor.player.worldObj, initPos.xCoord,
                                                                        initPos.yCoord, initPos.zCoord,
                                                                        look.xCoord, look.yCoord,
                                                                        look.zCoord);

        executor.player.worldObj.spawnEntityInWorld(fireball);

        executor.resolveOutput((short)5, true);
        return true;
    }
 
开发者ID:Drazuam,项目名称:RunicArcana,代码行数:35,代码来源:DustSymbolFireball.java

示例2: canSee

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
/**
 * checking if two Vec3d can see each other (there are not any block between)
 *
 * the started pos can be likely to:
 *                   for block: new Vec3d(pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5)
 *                   for entity: entity.getPositionVector().addVector(0, entity.getEyeHeight(), 0);
 *
 * @return if can see each other
 */
public static boolean canSee(World world, Vec3d traceStart, Vec3d traceEnd) {
    Vec3d vecDelta = new Vec3d(
            traceEnd.x - traceStart.x,
            traceEnd.y - traceStart.y,
            traceEnd.z - traceStart.z
    );

    // Normalize vector to the largest delta axis
    double vecDeltaLength = MathHelper.absMax(vecDelta.x, MathHelper.absMax(vecDelta.y, vecDelta.z));

    vecDelta = vecDelta.scale(1 / vecDeltaLength);

    // Limit how many non solid block a turret can see through
    for (int i = 0; i < 10; i++) {
        // Offset start position toward the target to prevent self collision
        traceStart = traceStart.add(vecDelta);

        RayTraceResult traced = world.rayTraceBlocks(traceStart.add(Vec3d.ZERO), traceEnd.add(Vec3d.ZERO));

        if (traced != null && traced.typeOfHit == RayTraceResult.Type.BLOCK) {
            IBlockState hitBlock = world.getBlockState(traced.getBlockPos());

            // If non solid block is in the way then proceed to continue
            // tracing
            if (hitBlock != null && !hitBlock.getMaterial().isSolid() && MathHelper.absMax(
                    MathHelper.absMax(traceStart.x - traceEnd.x, traceStart.y - traceEnd.y),
                    traceStart.z - traceEnd.z) > 1) {
                // Start at new position and continue
                traceStart = traced.hitVec;
                continue;
            }
        }
        return traced != null;
    }

    // If all above failed, the target cannot be seen
    return false;
}
 
开发者ID:MinecraftPangu,项目名称:Pangu,代码行数:48,代码来源:AIUtils.java

示例3: findExitPortal

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
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.world, 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.world, 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.world, 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.world, new Random(this.exitPortal.toLong()), this.exitPortal);
    }
    else
    {
        LOG.debug("Found block at {}", new Object[] {this.exitPortal});
    }

    this.exitPortal = findHighestBlock(this.world, 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();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:37,代码来源:TileEntityEndGateway.java

示例4: attackDirect

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
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);
				}
			}
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:32,代码来源:EntityProjectileBase.java

示例5: findExitPortal

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
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();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:37,代码来源:TileEntityEndGateway.java

示例6: movePlayer

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
private static void movePlayer(Vec3d destination, EntityPlayer player, boolean keepMomentum) {

        player.setPositionAndUpdate(destination.x, destination.y, destination.z);

        if(keepMomentum) {
            Vec3d velocity = player.getLookVec();
            velocity = velocity.scale(0.25);
            SPacketEntityVelocity p = new SPacketEntityVelocity(player.getEntityId(), velocity.x, velocity.y, velocity.z);
            ((EntityPlayerMP) player).connection.sendPacket(p);
        }
    }
 
开发者ID:ImbaKnugel,项目名称:Whoosh,代码行数:12,代码来源:TeleportUtil.java

示例7: shootBullet

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
public void shootBullet(EntityLivingBase owner) {
	this.setSoundState(this.getAmmo() > 0 ? 2 : 3);
	Vec3d attackPos = this.isControlled()
			? new Vec3d(this.getLookHelper().getLookPosX(), this.getLookHelper().getLookPosY(),
					this.getLookHelper().getLookPosZ())
			: this.getAttackTarget().getPositionVector().addVector(0, this.getAttackTarget().getEyeHeight(), 0);
	while (this.attackDelay <= 0 && this.getAmmo() > 0) {
		if(this.getOwnerId() != null && this.ticksExisted % 10 == 0)
			TF2Util.attractMobs(this, this.world);
		this.attackDelay += this.getLevel() > 1 ? 2.5f : 5f;
		if (this.isControlled())
			this.attackDelay /= 2;
		this.playSound(this.getLevel() == 1 ? TF2Sounds.MOB_SENTRY_SHOOT_1 : TF2Sounds.MOB_SENTRY_SHOOT_2, 1.5f,
				1f);
		List<RayTraceResult> list = TF2Util.pierce(this.world, this, this.posX,
				this.posY + this.getEyeHeight(), this.posZ, attackPos.x, attackPos.y, attackPos.z,
				false, 0.08f, false);
		for (RayTraceResult bullet : list)
			if (bullet.entityHit != null) {

				DamageSource src = TF2Util.causeDirectDamage(sentryBullet, owner, 0).setProjectile();

				if (TF2Util.dealDamage(bullet.entityHit, this.world, owner, this.sentryBullet,
						TF2Util.calculateCritPost(bullet.entityHit, null, 0, ItemStack.EMPTY), 1.6f, src)) {
					Vec3d dist = new Vec3d(bullet.entityHit.posX - this.posX, bullet.entityHit.posY - this.posY,
							bullet.entityHit.posZ - this.posZ).normalize();
					dist=dist.scale(0.25 * (this.getLevel()>1? 0.7 : 1));
					if(this.isControlled())
						dist=dist.scale(0.25);
					if(bullet.entityHit instanceof EntityLivingBase )
						dist=dist.scale(1-((EntityLivingBase) bullet.entityHit).getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE).getAttributeValue());
					if(dist.lengthSquared()>0f) {
						bullet.entityHit.addVelocity(dist.x, dist.y, dist.z);
						bullet.entityHit.isAirBorne=bullet.entityHit.motionY>0.05;
						if (bullet.entityHit instanceof EntityPlayerMP)
							TF2weapons.network.sendTo(new TF2Message.VelocityAddMessage(dist, bullet.entityHit.isAirBorne), (EntityPlayerMP) bullet.entityHit);
						
						if (bullet.entityHit instanceof EntityLivingBase) {
							((EntityLivingBase) bullet.entityHit).setLastAttackedEntity(this);
							((EntityLivingBase) bullet.entityHit).setRevengeTarget(this);
							if (!bullet.entityHit.isEntityAlive()) {
								this.setKills(this.getKills() + 1);
								if(owner instanceof EntityPlayer && bullet.entityHit instanceof EntityTF2Character && ++this.mercsKilled%5==0) {
									owner.getCapability(TF2weapons.PLAYER_CAP, null).completeObjective(Objective.KILLS_SENTRY, this.sentryBullet);
								}
									
							}
						}
					}
				}
			}
		this.setAmmo(this.getAmmo() - 1);
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:55,代码来源:EntitySentry.java

示例8: render

import net.minecraft.util.math.Vec3d; //导入方法依赖的package包/类
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc)
{
	if (((ExPWorld)IExPWorld.of(world)).rainTicksRemaining <= 0)
	{
		return;
	}
	
	GlStateManager.depthMask(true);
	Vec3d offset = IExPWorld.of(world).getWindDirection();
	offset = offset.scale(IExPWorld.of(world).getWindStrength() / 3);
	float wStr = IExPWorld.of(world).getWindStrength();
	Random rand = new Random();
	GlStateManager.disableCull();
	GlStateManager.enableBlend();
       GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
       GlStateManager.alphaFunc(516, 0.1F);
	mc.renderEngine.bindTexture(ExPTextures.WEATHER);
	Entity entity = mc.getRenderViewEntity();
	double d0 = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double)partialTicks;
       double d1 = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double)partialTicks;
       double d2 = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double)partialTicks;
       BlockPos pos = entity.getPosition();
	BufferBuilder vb = Tessellator.getInstance().getBuffer();
	vb.setTranslation(-d0, -d1, -d2);
	vb.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
	int x = pos.getX();
	int y = pos.getY();
	int z = pos.getZ();
	for (int dx = -8; dx <= 8; ++dx)
	{
		for (int dz = -8; dz <= 8; ++dz)
		{
			rand.setSeed(MathHelper.getCoordinateRandom(x + dx, 0, z + dz));
			int py = world.getPrecipitationHeight(pos.add(dx, 0, dz)).getY();
			py = Math.max(py, y - 8);
			double offsetYTex = rand.nextDouble() + (float)(world.getWorldTime() % 10) / 10 + partialTicks / 10;
			BlockPos renderedAt = new BlockPos(x + dx, py, z + dz);
			double offsetXTex = Helpers.getTemperatureAt(world, renderedAt) < 0 ? 0.5 : 0;
			float rOffX = rand.nextFloat() / 10;
			float rOffZ = rand.nextFloat() / 10;
			
			if (offsetXTex == 0.5)
			{
				float texOf = Math.max(2, 55 - wStr);
				offsetYTex = rand.nextDouble() + world.getWorldTime() % texOf / texOf + partialTicks / texOf;
			}
			
			int j3 = world.getCombinedLight(renderedAt, 0);
               int k3 = j3 >> 16 & 65535;
               int l3 = j3 & 65535;
			vb.pos(rOffX + x + 1 + dx - offset.x, py + 16, rOffZ + z + dz + 0.5 - offset.z).tex(offsetXTex, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + dx - offset.x, py + 16, rOffZ + z + dz + 0.5 - offset.z).tex(offsetXTex + 0.5, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + dx, py, rOffZ + z + dz + 0.5).tex(offsetXTex + 0.5, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 1 + dx, py, rOffZ + z + dz + 0.5).tex(offsetXTex, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx - offset.x, py + 16, rOffZ + z + dz + 1 - offset.z).tex(offsetXTex, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx - offset.x, py + 16, rOffZ + z + dz - offset.z).tex(offsetXTex + 0.5, offsetYTex + 4).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx , py, rOffZ + z + dz).tex(offsetXTex + 0.5, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
			vb.pos(rOffX + x + 0.5 + dx, py, z + rOffZ + dz + 1).tex(offsetXTex, offsetYTex).color(1, 1, 1, 0.5F).lightmap(k3, l3).endVertex();
		}
	}
	
	Tessellator.getInstance().draw();
	vb.setTranslation(0, 0, 0);
	GlStateManager.enableCull();
       GlStateManager.disableBlend();
       GlStateManager.alphaFunc(516, 0.1F);
       GlStateManager.depthMask(false);
}
 
开发者ID:V0idWa1k3r,项目名称:ExPetrum,代码行数:70,代码来源:WorldWeatherRenderer.java


注:本文中的net.minecraft.util.math.Vec3d.scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。