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


Java Horse类代码示例

本文整理汇总了Java中org.bukkit.entity.Horse的典型用法代码示例。如果您正苦于以下问题:Java Horse类的具体用法?Java Horse怎么用?Java Horse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: createHorse

import org.bukkit.entity.Horse; //导入依赖的package包/类
public static Horse createHorse(Player p, PlayerDataRPG pd) {
    Horse horse = (Horse) REntities.createLivingEntity(CustomHorse.class, p.getLocation());
    horse.setTamed(true);
    setHorseSpeed(horse, getSpeed(pd.horseSpeed));
    horse.setJumpStrength(getJump(pd.horseJump));
    horse.setColor(getColor(pd));
    horse.setStyle(getStyle(pd));
    horse.setVariant(getVariant(pd));
    horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
    if (pd.horseArmor != null)
        horse.getInventory().setArmor(new ItemStack(pd.horseArmor));
    if (pd.horseBaby) {
        horse.setBaby();
        horse.setAgeLock(true);
    }
    horse.setCustomName(p.getName() + "'s Horse");
    horse.setCustomNameVisible(true);
    pd.riding = true;
    horse.setPassenger(p);
    horseUUIDs.add(horse.getUniqueId());
    return horse;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:23,代码来源:HorseManager.java

示例2: createHorse

import org.bukkit.entity.Horse; //导入依赖的package包/类
private void createHorse(Player player, Location spawn) {
    player.teleport(spawn);
    Horse horse = spawn.getWorld().spawn(spawn, Horse.class);
    horse.setJumpStrength(0);

    double speed = this.getAPI().getGameManager().getGameState() == GameState.STARTING ? 0D : 0.7D;

    // TODO Fix this for 1.8
    horse.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(speed);

    Bukkit.getScheduler().runTaskLater(getAPI().getPlugin(), () -> {
        horse.addPassenger(player);
        horse.setTamed(true);
        horse.getInventory().setSaddle(new ItemStack(Material.SADDLE));
        horse.setAdult();
        horse.setOwner(player);
    }, 1L);
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:19,代码来源:HorseRaceGame.java

示例3: onMountPet

import org.bukkit.entity.Horse; //导入依赖的package包/类
@EventHandler
public void onMountPet(VehicleEnterEvent event) {
    if (event.getEntered().getType() != EntityType.PLAYER || event.getVehicle().getType() != EntityType.HORSE) {
        return;
    }

    Player player = (Player) event.getEntered();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    Horse vehicle = (Horse) event.getVehicle();
    if (PetManager.getPetFromEntity(vehicle, player) != null && player != vehicle.getOwner()) {
        PlayerUtils.sendMessage(player, RPGInventory.getLanguage().getMessage("error.mount.owner", vehicle.getOwner().getName()));
        event.setCancelled(true);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:18,代码来源:PetListener.java

示例4: onPetInventoryOpened

import org.bukkit.entity.Horse; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPetInventoryOpened(InventoryOpenEvent event) {
    Player player = (Player) event.getPlayer();
    if (!InventoryManager.playerIsLoaded(player)) {
        return;
    }

    final PlayerWrapper playerWrapper = InventoryManager.get(player);
    if (playerWrapper.hasPet() && event.getInventory().getHolder() == playerWrapper.getPet()) {
        playerWrapper.openInventory();
        event.setCancelled(true);

        new BukkitRunnable() {
            @Override
            public void run() {
                HorseInventory horseInv = ((Horse) playerWrapper.getPet()).getInventory();
                horseInv.setSaddle(new ItemStack(Material.SADDLE));
            }
        }.runTaskLater(RPGInventory.getInstance(), 1);
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:22,代码来源:PetListener.java

示例5: rawset

import org.bukkit.entity.Horse; //导入依赖的package包/类
@Override
public void rawset(LuaValue key, LuaValue value) {
    if (key.isstring()) {
        switch (key.checkjstring()) {
            case "style":
                getHorseTrait().setStyle(ScriptUtil.enumValue(value, Horse.Style.class));
                break;
            case "variant":
                getHorseTrait().setVariant(ScriptUtil.enumValue(value, Horse.Variant.class));
                break;
            case "color":
                getHorseTrait().setColor(ScriptUtil.enumValue(value, Horse.Color.class));
                break;
            case "jumpStrength":
                getHorseTrait().setJumpStrength(value.checkdouble());
                break;
            case "domestication":
                getHorseTrait().setDomestication(value.checkint());
                break;
            case "maxDomestication":
                getHorseTrait().setMaxDomestication(value.checkint());
                break;
        }
    }
    super.rawset(key, value);
}
 
开发者ID:leMaik,项目名称:RpgPlus,代码行数:27,代码来源:HorseEntityWrapper.java

示例6: handleMetadataPacket

import org.bukkit.entity.Horse; //导入依赖的package包/类
/**
 * Examine an EntityMetadata packet and if it is for a dead horse, modify it to reflect the actual
 * value of the horse's armor.
 * 
 * @param event PacketEvent to examine and potentially modify.
 */
private void handleMetadataPacket(PacketEvent event) {
  Entity entity = event.getPacket().getEntityModifier(event).read(ENTITY_INDEX);
  if (entity != null && entity.getType() == EntityType.HORSE) {
    switch (((Horse) entity).getVariant()) {
      default:
        return;
      case SKELETON_HORSE:
      case UNDEAD_HORSE:
        List<WrappedWatchableObject> watchables =
            event.getPacket().getWatchableCollectionModifier().read(WATCHABLE_INDEX);
        for (WrappedWatchableObject watchable : watchables) {
          if (watchable.getIndex() == ARMOR_INDEX) {
            int armor = getArmorMetadataValue((Horse) entity);
            // if (!watchable.getValue().equals(armor)) {
            watchable.setValue(armor, true);
            // }
            return;
          }
        }
    }
  }
}
 
开发者ID:EasyMFnE,项目名称:DeadHorses,代码行数:29,代码来源:DeadHorses.java

示例7: apply

import org.bukkit.entity.Horse; //导入依赖的package包/类
@Override
public boolean apply(Entity entity) {
    PreCon.notNull(entity);
    PreCon.isValid(entity instanceof Horse, "org.bukkit.entity.Horse expected.");

    Horse horse = (Horse) entity;

    horse.setColor(_color);
    horse.setVariant(_variant);
    horse.setStyle(_style);
    horse.setMaxDomestication(_maxDomestication);
    horse.setDomestication(_domestication);
    horse.setCarryingChest(_hasChest);
    horse.setJumpStrength(_jumpStrength);
    return true;
}
 
开发者ID:JCThePants,项目名称:NucleusFramework,代码行数:17,代码来源:HorseAnimal.java

示例8: racetrackNearby

import org.bukkit.entity.Horse; //导入依赖的package包/类
private boolean racetrackNearby(Horse h)
{

    int range = plugin.getConfig().getInt("RaceLine.NoJumpRange");
    for (int x = -range; x < range; x++)
    {
        for (int y = -range; y < range; y++)
        {
            for (int z = -range; z < range; z++)
            {
                if (EquestrianDash.LapCuboid.contains(h.getLocation().add(x, y, z).getBlock()))
                {
                    return true;
                }
            }
        }
    }

    return false;
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:21,代码来源:HorseJumpListener.java

示例9: killallHorses

import org.bukkit.entity.Horse; //导入依赖的package包/类
public static void killallHorses(World w) // RIP in peace D:
{
    List<Horse> toremove = new ArrayList<>();

    for (Entity e : w.getEntities())
    {
        if (e instanceof Horse)
        {
            toremove.add((Horse) e);
        }
    }

    for (Horse h : toremove)
    {
        h.remove();
    }

    EquestrianDash.plugin.getLogger().info("Removed " + toremove.size() + " horse(s).");
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:20,代码来源:WorldLoadListener.java

示例10: run

import org.bukkit.entity.Horse; //导入依赖的package包/类
@Override
public void run()
{
    for(Map.Entry<UUID, Location> entry : players.entrySet())
    {
        Player p = Bukkit.getPlayer(entry.getKey());
        Entity v = p.getVehicle();

        if(v == null || !(v instanceof Horse))
        {
            continue;
        }

        Location loc = entry.getValue();
        Horse h = (Horse) p.getVehicle();
        h.teleport(loc);
        p.teleport(loc);
    }
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:20,代码来源:MovementTask.java

示例11: disableMovement

import org.bukkit.entity.Horse; //导入依赖的package包/类
public void disableMovement(final Player p, Horse h)
{
    new BukkitRunnable()
    {
        @Override
        public void run()
        {
            FileConfiguration data = plugin.getGameHandler().getCurrentTrack().getTrackData();

            if (data.getBoolean("NMS.Enabled"))
            {
                setNMSHorseSpeed(h, 0);
            }
            else
            {
                p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 999999999, 999999999));
                h.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 999999999, 999999999));
            }
        }
    }.runTaskLater(plugin, 1);
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:22,代码来源:PropertyHandler.java

示例12: respawnPlayer

import org.bukkit.entity.Horse; //导入依赖的package包/类
public void respawnPlayer(final Player p)
{
    if (p.getVehicle() != null && p.getVehicle() instanceof Horse)
    {
        Horse h = (Horse) p.getVehicle();
        h.setPassenger(null);
        h.setOwner(null);
        h.remove();
    }

    p.getWorld().playSound(p.getLocation(), Sound.WITHER_SPAWN, 3, 1);
    p.setHealth(p.getMaxHealth());
    Location loc = lastLocation.get(p.getUniqueId());
    p.teleport(loc);

    p.getInventory().clear();
    p.setFireTicks(0);
    plugin.getPropertyHandler().generateHorse(p, loc);
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:20,代码来源:RacerHandler.java

示例13: destroyGarbage

import org.bukkit.entity.Horse; //导入依赖的package包/类
public void destroyGarbage()
{
    int i = 0;
    for (Location loc : DespawningIce)
    {
        loc.getBlock().setType(Material.AIR);
        i++;
    }

    plugin.getLogger().info("Destroying " + i + " undeleted Ice Powerup blocks.");

    List<Track> tracks = plugin.getTrackRegistry().getTracks();
    for (Track track : tracks)
    {
        track.getItemBoxes().forEach(ItemBox::despawn);

        Collection<Marker> markers = track.getMarkerHandler().getMarkers().values();

        for (Marker marker : markers)
        {
            marker.setVisualized(false);
        }

        track.getWorld().getEntities().stream().filter(e -> e instanceof EnderCrystal || e instanceof Horse || e.hasMetadata("MarkerLocation") || e.getName().startsWith("§9Marker")).forEach(Entity::remove);
    }
}
 
开发者ID:ColonelHedgehog,项目名称:Equestrian-Dash,代码行数:27,代码来源:GarbageControl.java

示例14: onPlayerInteractEntity

import org.bukkit.entity.Horse; //导入依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
    if (event.getRightClicked() instanceof Horse) {
        Horse horse = (Horse) event.getRightClicked();
        if (horse.isTamed()) {
            if (horse.getOwner() != event.getPlayer()) {
                event.setCancelled(true);
            }
        }
    }
    if (plugin.isUntaming(event.getPlayer())) {
        if (event.getRightClicked() instanceof Tameable) {
            Tameable tameable = (Tameable) event.getRightClicked();
            if (tameable.getOwner() == event.getPlayer() || event.getPlayer().hasPermission("wayward.travel.untame.any")) {
                tameable.setTamed(false);
                event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.GREEN + "Your tameable creature was untamed.");
            } else {
                event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.RED + "That tameable creature is not yours!");
            }
        } else {
            event.getPlayer().sendMessage(plugin.getPrefix() + ChatColor.RED + "That entity is not tameable!");
        }
        plugin.setUntaming(event.getPlayer(), false);
    }
}
 
开发者ID:WaywardRealms,项目名称:Wayward,代码行数:26,代码来源:HorsePlayerInteractEntityListener.java

示例15: applyMountData

import org.bukkit.entity.Horse; //导入依赖的package包/类
@Override
public void applyMountData(Entity npc) {
	super.applyMountData(npc);

	if (!(npc instanceof Horse)) {
		return;
	}

	Horse horse = (Horse) npc;

	if (colour != null) {
		horse.setColor(colour);
	}

	if (style != null) {
		horse.setStyle(style);
	}

	if (variant != null) {
		horse.setVariant(variant);
	}
}
 
开发者ID:CodingBadgers,项目名称:MineKart,代码行数:23,代码来源:HorseMountData.java


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