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


Java Vector.getY方法代码示例

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


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

示例1: onPlayerJump

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJump(PlayerMoveEvent event) {
    Player player = event.getPlayer();

    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Vector velocity = player.getVelocity();
    Modifier jumpModifier = ItemManager.getModifier(player, ItemStat.StatType.JUMP);

    if (jumpModifier.getBonus() == 0 && jumpModifier.getMultiplier() == 1) {
        return;
    }

    // === START: Magic constants ===
    if (velocity.getY() == 0.41999998688697815D) {
        double jump = (1.5 + Math.sqrt(jumpModifier.getBonus())) * jumpModifier.getMultiplier();
        Vector moveDirection = event.getTo().toVector().subtract(event.getFrom().toVector());
        velocity.setX(moveDirection.getX() * jump * player.getWalkSpeed());
        velocity.setY(velocity.getY() * jump / 1.5);
        velocity.setZ(moveDirection.getZ() * jump * player.getWalkSpeed());
        player.setVelocity(velocity);
    }
    // === END: Magic constants ===
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:27,代码来源:ItemListener.java

示例2: intersects

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static boolean intersects(Vector position, Vector min, Vector max) {
    if (position.getX() < min.getX() || position.getX() > max.getX()) {
        return false;
    } else if (position.getY() < min.getY() || position.getY() > max.getY()) {
        return false;
    } else if (position.getZ() < min.getZ() || position.getZ() > max.getZ()) {
        return false;
    }
    return true;
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:11,代码来源:RayTrace.java

示例3: BoundingBox

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public BoundingBox(Vector min, Vector max) {
    this.minX = min.getX();
    this.minY = min.getY();
    this.minZ = min.getZ();
    this.maxX = max.getX();
    this.maxY = max.getY();
    this.maxZ = max.getZ();
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:9,代码来源:BoundingBox.java

示例4: CylindricalRegion

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public CylindricalRegion(Vector base, double radius, double top) {
    checkArgument(radius >= 0);
    checkArgument(Double.isFinite(base.getX()));
    checkArgument(Double.isFinite(base.getZ()));

    this.center = ImVector.of(base.getX(), 0, base.getZ());
    this.bottom = base.getY();
    this.top = top;
    this.radius = radius;
    this.radiusSq = radius * radius;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:12,代码来源:CylindricalRegion.java

示例5: getAngle

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public float getAngle(Vector from) {
    double dx = this.target.getX() - from.getX();
    double dz = this.target.getZ() - from.getZ();
    double distance = Math.sqrt(dx * dx + dz * dz);
    double dy = this.target.getY() - (from.getY() + 1.62); // add eye height so player actually looks at point
    return (float) Math.toDegrees(Math.atan2(-dy, distance));
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:DirectedPitchProvider.java

示例6: setDirection

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void setDirection(Vector direction) {
    Validate.notNull(direction, "Direction can not be null");
    double x = direction.getX();
    double y = direction.getY();
    double z = direction.getZ();
    double magnitude = (double) MathHelper.sqrt_double(x * x + y * y + z * z);
    getHandle().accelerationX = x / magnitude;
    getHandle().accelerationY = y / magnitude;
    getHandle().accelerationZ = z / magnitude;
}
 
开发者ID:UraniumMC,项目名称:Uranium,代码行数:11,代码来源:CraftFireball.java

示例7: spawn

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void spawn(Player viewer, Location location, Vector velocity) {
    entity.setPositionRotation(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
    entity.motX = velocity.getX();
    entity.motY = velocity.getY();
    entity.motZ = velocity.getZ();
    sendPacket(viewer, spawnPacket());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:NMSHacks.java

示例8: ParticlePacket

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public ParticlePacket(ParticleEffect effect, Vector direction, float speed, boolean longDistance, ParticleData data) throws IllegalArgumentException {
    this(effect, (float) direction.getX(), (float) direction.getY(), (float) direction.getZ(), speed, 0, longDistance, data);
}
 
开发者ID:Shynixn,项目名称:BlockBall,代码行数:4,代码来源:ParticleEffect.java

示例9: doBlockDrops

import org.bukkit.util.Vector; //导入方法依赖的package包/类
/**
 * This is not an event handler. It is called explicitly by BlockTransformListener
 * after all event handlers have been called.
 */
@SuppressWarnings("deprecation")
public void doBlockDrops(final BlockTransformEvent event) {
    if(!causesDrops(event.getCause())) {
        return;
    }

    final BlockDrops drops = event.getDrops();
    if(drops != null) {
        event.setCancelled(true);
        final BlockState oldState = event.getOldState();
        final BlockState newState = event.getNewState();
        final Block block = event.getOldState().getBlock();
        final int newTypeId = newState.getTypeId();
        final byte newData = newState.getRawData();

        block.setTypeIdAndData(newTypeId, newData, true);

        boolean explosion = false;
        MatchPlayer player = ParticipantBlockTransformEvent.getParticipant(event);

        if(event.getCause() instanceof EntityExplodeEvent) {
            EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
            explosion = true;

            if(drops.fallChance != null &&
               oldState.getType().isBlock() &&
               oldState.getType() != Material.AIR &&
               this.getMatch().getRandom().nextFloat() < drops.fallChance) {

                FallingBlock fallingBlock = event.getOldState().spawnFallingBlock();
                fallingBlock.setDropItem(false);

                if(drops.landChance != null && this.getMatch().getRandom().nextFloat() >= drops.landChance) {
                    this.fallingBlocksThatWillNotLand.add(fallingBlock);
                }

                Vector v = fallingBlock.getLocation().subtract(explodeEvent.getLocation()).toVector();
                double distance = v.length();
                v.normalize().multiply(BASE_FALL_SPEED * drops.fallSpeed / Math.max(1d, distance));

                // A very simple deflection model. Check for a solid
                // neighbor block and "bounce" the velocity off of it.
                Block west = block.getRelative(BlockFace.WEST);
                Block east = block.getRelative(BlockFace.EAST);
                Block down = block.getRelative(BlockFace.DOWN);
                Block up = block.getRelative(BlockFace.UP);
                Block north = block.getRelative(BlockFace.NORTH);
                Block south = block.getRelative(BlockFace.SOUTH);

                if((v.getX() < 0 && west != null && Materials.isColliding(west.getType())) ||
                    v.getX() > 0 && east != null && Materials.isColliding(east.getType())) {
                    v.setX(-v.getX());
                }

                if((v.getY() < 0 && down != null && Materials.isColliding(down.getType())) ||
                    v.getY() > 0 && up != null && Materials.isColliding(up.getType())) {
                    v.setY(-v.getY());
                }

                if((v.getZ() < 0 && north != null && Materials.isColliding(north.getType())) ||
                    v.getZ() > 0 && south != null && Materials.isColliding(south.getType())) {
                    v.setZ(-v.getZ());
                }

                fallingBlock.setVelocity(v);
            }
        }

        dropObjects(drops, player, newState.getLocation(), 1d, explosion);

    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:77,代码来源:BlockDropsMatchModule.java

示例10: blockAlign

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public BlockVector blockAlign(Vector vector) {
    return new BlockVector((int) vector.getX() + 0.5d, (int) vector.getY() + 0.5d, (int) vector.getZ() + 0.5d);
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:4,代码来源:RegionSave.java

示例11: setVelocity

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void setVelocity(Vector vector) {
    ((CraftArmorStand)armorStand).getHandle().motX = vector.getX();
    ((CraftArmorStand)armorStand).getHandle().motY = vector.getY();
    ((CraftArmorStand)armorStand).getHandle().motZ = vector.getZ();
}
 
开发者ID:SamaGames,项目名称:AgarMC,代码行数:6,代码来源:Cell.java

示例12: onLive

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void onLive() {
      if (this.pet == null) {
          this.remove(false);
          return;
      }

      if (this.getPlayerOwner() == null || !this.getPlayerOwner().isOnline()) {
          EchoPet.getManager().removePet(this.getPet(), true);
          return;
      }

if(pet.isOwnerRiding() && passenger == null && !pet.isOwnerInMountingProcess()){
          pet.ownerRidePet(false);
      }

      if (((CraftPlayer) this.getPlayerOwner()).getHandle().isInvisible() != this.isInvisible() && !this.shouldVanish) {
          this.setInvisible(!this.isInvisible());
      }

      if (((CraftPlayer) this.getPlayerOwner()).getHandle().isSneaking() != this.isSneaking()) {
          this.setSneaking(!this.isSneaking());
      }

      if (((CraftPlayer) this.getPlayerOwner()).getHandle().isSprinting() != this.isSprinting()) {
          this.setSprinting(!this.isSprinting());
      }

      if (this.getPet().isHat()) {
          this.lastYaw = this.yaw = (this.getPet().getPetType() == PetType.ENDERDRAGON ? this.getPlayerOwner().getLocation().getYaw() - 180 : this.getPlayerOwner().getLocation().getYaw());
      }

      if (this.getPlayerOwner().isFlying() && EchoPet.getOptions().canFly(this.getPet().getPetType())) {
          Location petLoc = this.getLocation();
          Location ownerLoc = this.getPlayerOwner().getLocation();
          Vector v = ownerLoc.toVector().subtract(petLoc.toVector());

          double x = v.getX();
          double y = v.getY();
          double z = v.getZ();

          Vector vo = this.getPlayerOwner().getLocation().getDirection();
          if (vo.getX() > 0) {
              x -= 1.5;
          } else if (vo.getX() < 0) {
              x += 1.5;
          }
          if (vo.getZ() > 0) {
              z -= 1.5;
          } else if (vo.getZ() < 0) {
              z += 1.5;
          }

          this.setVelocity(new Vector(x, y, z).normalize().multiply(0.3F));
      }
  }
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:56,代码来源:EntityPet.java

示例13: fakeDelta

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public static void fakeDelta(Player observer, Player victim, Vector delta) {
    Packet packet = new PacketPlayOutEntity.PacketPlayOutRelEntityMove(((CraftPlayer) victim).getHandle().getId(), (byte) (delta.getX() * 32), (byte) (delta.getY() * 32), (byte) (delta.getZ() * 32), false /* on ground */);

    sendPacket((CraftPlayer) observer, packet);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:6,代码来源:RocketUtils.java

示例14: setVelocity

import org.bukkit.util.Vector; //导入方法依赖的package包/类
public void setVelocity(Vector vel){
	this.motX = vel.getX();
	this.motY = vel.getY();
	this.motZ = vel.getZ();
	this.velocityChanged = true;
}
 
开发者ID:Borlea,项目名称:EchoPet,代码行数:7,代码来源:EntityPet.java

示例15: run

import org.bukkit.util.Vector; //导入方法依赖的package包/类
@Override
public void run()
{
    final Location playerLocation = player.getLocation();


    // Checks if the player is still on the line

    Vector position   = playerLocation.toVector();
    Vector origin     = getStart().toVector();
    Vector director   = yodel.getAngleVector();
    double k;

    if (isZero(origin)) origin = getEnd().toVector();

    try
    {
        k = director.getX() * (position.getX() - origin.getX())
                + director.getY() * (position.getY() - origin.getY())
                + director.getZ() * (position.getZ() - origin.getZ());

        k /= NumberConversions.square(director.getX())
                + NumberConversions.square(director.getY())
                + NumberConversions.square(director.getZ());
    }
    catch (ArithmeticException e)
    {
        this.hub.getLogger().log(Level.SEVERE, "Division by zero while checking route on yodel, remains unfixed", e);
        return;
    }

    Vector projection = origin.add(director.multiply(k));

    if (projection.distanceSquared(position) > 4)
    {
        player.teleport(projection.toLocation(playerLocation.getWorld()).setDirection(playerLocation.getDirection()));
    }


    // Updates the velocity

    player.setVelocity(velocityStep);
    player.setFallDistance(0);


    // Checks if the line is finished (either we are on the finish zone, or out of the path if for some
    // reason the landing zone was not entered)

    if (playerLocation.distanceSquared(getEnd()) < 6
            || playerLocation.distanceSquared(getStart()) > yodel.getLength() + 10)
    {
        this.yodel.stop(player);
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:55,代码来源:YodelRunner.java


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