本文整理匯總了Java中org.bukkit.entity.Ocelot類的典型用法代碼示例。如果您正苦於以下問題:Java Ocelot類的具體用法?Java Ocelot怎麽用?Java Ocelot使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Ocelot類屬於org.bukkit.entity包,在下文中一共展示了Ocelot類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCommand
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
protected void onCommand(CommandSender sender, String[] args) {
Player p = (Player) sender;
Ocelot cat = (Ocelot) p.getWorld().spawnEntity(p.getLocation(), EntityType.OCELOT);
if (cat == null)
return; // Probably in a protected area.
cat.setCatType(Utils.randElement(Ocelot.Type.values()));
cat.setTamed(true);
cat.setBaby();
cat.setVelocity(p.getEyeLocation().getDirection().multiply(2));
Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
cat.getWorld().createExplosion(cat.getLocation(), 0F);
cat.remove();
}, 20L);
}
示例2: run
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
public void run(PAUser user, String label, String... args) {
final Ocelot o = (Ocelot) user.getLoc().getWorld().spawnEntity(user.getLoc(), EntityType.OCELOT);
o.setCatType(Ocelot.Type.values()[r.nextInt(Ocelot.Type.values().length)]);
o.setSitting(true);
o.setTamed(true);
o.setAge(r.nextInt(2));
o.setCustomName(Utils.colorize("&dGateteeeeeee"));
o.setCustomNameVisible(true);
o.setNoDamageTicks(Integer.MAX_VALUE);
o.setVelocity(user.getPlayer().getLocation().getDirection().multiply(2));
PAServer.users.forEach(u -> u.sendSound(Sounds.CAT_MEOW));
plugin.getServer().getScheduler().runTaskLater(plugin, () -> {
PAServer.users.forEach(u -> u.sendSound(Sounds.EXPLODE));
ParticleEffect.EXPLOSION_HUGE.send(plugin.getServer().getOnlinePlayers(), o.getLocation(), 0, 0, 0, 1, 20, 50);
o.remove();
}, 60);
}
示例3: OcelotMenu
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
/**
* {@inheritDoc}
*/
public OcelotMenu(Plot plot, Ocelot ocelot) {
super(plot, ocelot);
//type
ItemStack type = new ItemStack(Material.BONE);
ItemMeta typeMeta = type.getItemMeta();
typeMeta.setDisplayName(ChatColor.GREEN + "Change type");
type.setItemMeta(typeMeta);
insertItem(type, event -> {
new OcelotTypeMenu(ocelot).open((Player) event.getWhoClicked());
event.setCancelled(true);
}, 0);
}
示例4: freePet
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
/**
* Frees a pet; it will no longer be tamed.
*
* @param event
* @param oldOwner
*/
private void freePet(PlayerInteractEntityEvent event, AnimalTamer oldOwner) {
if (chargePrice(event.getPlayer(), freePetPrice)) {
Tameable tameableAnimal = (Tameable) event.getRightClicked();
// Free pet.
tameableAnimal.setTamed(false);
// Make freed pet stand up.
if (version >= 12 && tameableAnimal instanceof Sittable) {
((Sittable) tameableAnimal).setSitting(false);
} else if (tameableAnimal instanceof Wolf) {
((Wolf) tameableAnimal).setSitting(false);
} else if (tameableAnimal instanceof Ocelot) {
((Ocelot) tameableAnimal).setSitting(false);
}
event.getPlayer().sendMessage(plugin.getChatHeader()
+ plugin.getPluginLang().getString("pet-freed", "Say goodbye: this pet returned to the wild!"));
// Create new event to allow other plugins to be aware of the freeing.
PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent(
oldOwner, null, tameableAnimal);
Bukkit.getServer().getPluginManager().callEvent(playerChangeAnimalOwnershipEvent);
}
}
示例5: throwKittyCannon
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
private void throwKittyCannon(final World world, Player player, Location hookLoc) {
int i = random.nextInt(Ocelot.Type.values().length);
final Ocelot cat = (Ocelot) throwMob(world, player, hookLoc, EntityType.OCELOT);
cat.setCatType(Ocelot.Type.values()[i]);
cat.setTamed(true);
cat.setBaby();
mainInstance.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
final Location catLoc = cat.getLocation();
cat.remove();
world.createExplosion(catLoc.getX(), catLoc.getY(), catLoc.getZ(), 2.0F, false, false);
}
}, 20);
}
示例6: run
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final EntityType cat = EntityType.OCELOT;
final Ocelot ocelot = (Ocelot)user.getPlayer().getWorld().spawn(user.getPlayer().getEyeLocation(), cat.getEntityClass());
if (ocelot == null)
{
return;
}
final int i = random.nextInt(Ocelot.Type.values().length);
ocelot.setCatType(Ocelot.Type.values()[i]);
ocelot.setTamed(true);
ocelot.setVelocity(user.getPlayer().getEyeLocation().getDirection().multiply(2));
ess.getPlugin().scheduleSyncDelayedTask(
new Runnable()
{
@Override
public void run()
{
final Location loc = ocelot.getLocation();
ocelot.remove();
loc.getWorld().createExplosion(loc, 0F);
}
}, 20);
}
示例7: onLoad
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public void onLoad() {
add(Ocelot.Type.WILD_OCELOT, "Wild Ocelot", "Wild", "WI", "W", "Untamed", "Default", "Def", "None");
add(Ocelot.Type.BLACK_CAT, "Black Cat", "Black", "BL", "B");
add(Ocelot.Type.RED_CAT, "Red Cat", "Red", "RE", "R");
add(Ocelot.Type.SIAMESE_CAT, "Siamese Cat", "Siamese", "SI", "S", "Siam");
}
示例8: initiateEntityPet
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public void initiateEntityPet() {
super.initiateEntityPet();
getBukkitEntity().setTamed(true);
getBukkitEntity().setCatType(Ocelot.Type.BLACK_CAT);
getBukkitEntity().setOwner(getPlayerOwner());
}
示例9: rawset
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public void rawset(LuaValue key, LuaValue value) {
if (key.isstring()) {
switch (key.checkjstring()) {
case "type":
getOcelotTrait().setCatType(ScriptUtil.enumValue(value, Ocelot.Type.class));
break;
}
}
super.rawset(key, value);
}
示例10: callOfTheWild
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
/**
* Handle the Call of the Wild ability.
*
* @param type The type of entity to summon.
* @param summonAmount The amount of material needed to summon the entity
*/
private void callOfTheWild(EntityType type, int summonAmount) {
Player player = getPlayer();
ItemStack heldItem = player.getItemInHand();
int heldItemAmount = heldItem.getAmount();
if (heldItemAmount < summonAmount) {
player.sendMessage(LocaleLoader.getString("Skills.NeedMore", StringUtils.getPrettyItemString(heldItem.getType())));
return;
}
if (!rangeCheck(type)) {
return;
}
int amount = Config.getInstance().getTamingCOTWAmount(type);
for (int i = 0; i < amount; i++) {
LivingEntity entity = (LivingEntity) player.getWorld().spawnEntity(player.getLocation(), type);
FakeEntityTameEvent event = new FakeEntityTameEvent(entity, player);
mcMMO.p.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
continue;
}
entity.setMetadata(mcMMO.entityMetadataKey, mcMMO.metadataValue);
((Tameable) entity).setOwner(player);
entity.setRemoveWhenFarAway(false);
switch (type) {
case OCELOT:
((Ocelot) entity).setCatType(Ocelot.Type.values()[1 + Misc.getRandom().nextInt(3)]);
break;
case WOLF:
entity.setMaxHealth(20.0);
entity.setHealth(entity.getMaxHealth());
break;
case HORSE:
Horse horse = (Horse) entity;
entity.setMaxHealth(15.0 + (Misc.getRandom().nextDouble() * 15));
entity.setHealth(entity.getMaxHealth());
horse.setColor(Horse.Color.values()[Misc.getRandom().nextInt(Horse.Color.values().length)]);
horse.setStyle(Horse.Style.values()[Misc.getRandom().nextInt(Horse.Style.values().length)]);
horse.setJumpStrength(Math.max(AdvancedConfig.getInstance().getMinHorseJumpStrength(), Math.min(Math.min(Misc.getRandom().nextDouble(), Misc.getRandom().nextDouble()) * 2, AdvancedConfig.getInstance().getMaxHorseJumpStrength())));
//TODO: setSpeed, once available
break;
default:
break;
}
if (Permissions.renamePets(player)) {
entity.setCustomName(LocaleLoader.getString("Taming.Summon.Name.Format", player.getName(), StringUtils.getPrettyEntityTypeString(type)));
entity.setCustomNameVisible(true);
}
}
player.setItemInHand(heldItemAmount == summonAmount ? null : new ItemStack(heldItem.getType(), heldItemAmount - summonAmount));
player.sendMessage(LocaleLoader.getString("Taming.Summon.Complete"));
}
示例11: OcelotAnimal
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
public OcelotAnimal(Entity entity) {
PreCon.isValid(entity instanceof Ocelot, "org.bukkit.entity.Ocelot expected.");
Ocelot ocelot = (Ocelot)entity;
_type = ocelot.getCatType();
_isSitting = ocelot.isSitting();
}
示例12: apply
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public boolean apply(Entity entity) {
PreCon.notNull(entity);
PreCon.isValid(entity instanceof Ocelot, "org.bukkit.entity.Ocelot expected.");
Ocelot ocelot = (Ocelot)entity;
ocelot.setCatType(_type);
ocelot.setSitting(_isSitting);
return true;
}
示例13: load
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
protected void load(ConfigurationSection config) {
super.load(config);
String catTypeName = config.getString("catType");
try {
catType = Ocelot.Type.valueOf(catTypeName);
} catch (Exception e) {
}
}
示例14: getSubItemData
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
private short getSubItemData(Ocelot.Type catType) {
switch (catType) {
case BLACK_CAT:
return DyeColor.BLACK.getWoolData();
case RED_CAT:
return DyeColor.RED.getWoolData();
case SIAMESE_CAT:
return DyeColor.SILVER.getWoolData();
case WILD_OCELOT:
default:
return DyeColor.ORANGE.getWoolData();
}
}
示例15: getDefaultTargetingBehaviours
import org.bukkit.entity.Ocelot; //導入依賴的package包/類
@Override
public BehaviourItem[] getDefaultTargetingBehaviours() {
return new BehaviourItem[]{
new BehaviourItem(1, new BehaviourFloat(this)),
new BehaviourItem(2, new BehaviourSwell(this)),
new BehaviourItem(3, new BehaviourAvoidEntity(this, Ocelot.class, 6.0F, 1.0D, 1.2D)),
new BehaviourItem(4, new BehaviourMeleeAttack(this, false, 1.0D)),
new BehaviourItem(5, new BehaviourRandomStroll(this, 0.8D)),
new BehaviourItem(6, new BehaviourLookAtNearestEntity(this, HumanEntity.class, 8F)),
new BehaviourItem(7, new BehaviourLookAtRandom(this))
};
}