本文整理汇总了Java中net.minecraft.util.math.Vec3d类的典型用法代码示例。如果您正苦于以下问题:Java Vec3d类的具体用法?Java Vec3d怎么用?Java Vec3d使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vec3d类属于net.minecraft.util.math包,在下文中一共展示了Vec3d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renderBrokenItemStack
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
/**
* 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())});
}
}
示例2: generateBranch
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
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));
}
示例3: onExecutionStart
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
@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);
}
示例4: pathFollow
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
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);
}
示例5: getFogColor
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
@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;
}
示例6: updateTask
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
/**
* 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);
}
}
示例7: isPositionClear
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
/**
* 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;
}
示例8: setPortal
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
/**
* 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;
}
}
示例9: shouldExecute
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
/**
* 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;
}
}
示例10: renderBrokenItemStack
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
/**
* 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())});
}
}
示例11: renderBase
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
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();
}
示例12: tick
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
@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();
}
示例13: rayTrace
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
@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);
}
示例14: canEntityBeSeen
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
/** 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;
}
}
示例15: getAngleToClientRotation
import net.minecraft.util.math.Vec3d; //导入依赖的package包/类
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;
}