本文整理汇总了Java中org.bukkit.entity.Ageable类的典型用法代码示例。如果您正苦于以下问题:Java Ageable类的具体用法?Java Ageable怎么用?Java Ageable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Ageable类属于org.bukkit.entity包,在下文中一共展示了Ageable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@Override
protected void execute(Event e) {
if (entity != null) {
if (marker == 1) {
if (Ageable.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Ageable)entity.getSingle(e)).setBaby();
} else if (Zombie.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Zombie)entity.getSingle(e)).setBaby(true);
}
} else {
if (Ageable.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Ageable)entity.getSingle(e)).setAdult();
} else if (Zombie.class.isAssignableFrom(entity.getSingle(e).getClass())) {
((Zombie)entity.getSingle(e)).setBaby(false);
}
}
}
}
示例2: check
import org.bukkit.entity.Ageable; //导入依赖的package包/类
public boolean check(Event e) {
if (entity.getSingle(e) instanceof Ageable) {
if (((Ageable)entity.getSingle(e)).isAdult()) {
return isNegated();
} else {
return !isNegated();
}
} else if (entity.getSingle(e) instanceof Zombie) {
if (((Zombie)entity.getSingle(e)).isBaby()) {
return !isNegated();
} else {
return isNegated();
}
}
return false;
}
示例3: BabyMenu
import org.bukkit.entity.Ageable; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public BabyMenu(Plot plot, Entity entity) {
super(plot, entity);
ItemStack baby = new ItemStack(Material.EGG);
ItemMeta babyMeta = baby.getItemMeta();
babyMeta.setDisplayName(ChatColor.GREEN + "Change to baby/adult");
baby.setItemMeta(babyMeta);
insertItem(baby, event -> {
if (entity instanceof Ageable) {
Ageable ageable = (Ageable) entity;
if (ageable.isAdult())
ageable.setBaby();
else
ageable.setAdult();
} else if (entity instanceof Zombie) {
Zombie zombie = (Zombie) entity;
zombie.setBaby(!zombie.isBaby());
}
event.setCancelled(true);
}, 0);
}
示例4: tick
import org.bukkit.entity.Ageable; //导入依赖的package包/类
protected void tick(Block b) throws Exception {
for (Entity n: me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).getNearbyEntities(3D, 3D, 3D)) {
if (n instanceof Ageable && !((Ageable) n).isAdult()) {
for (int slot: getInputSlots()) {
if (SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false)) {
if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
((Ageable) n).setAge(((Ageable) n).getAge() + 2000);
if (((Ageable) n).getAge() > 0) ((Ageable) n).setAge(0);
ParticleEffect.VILLAGER_HAPPY.display(((LivingEntity) n).getEyeLocation(), 0.2F, 0.2F, 0.2F, 0, 8);
return;
}
}
}
}
}
示例5: onEntityDamageByEntityEvent
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
Location l = BukkitUtil.getLocation(damager);
if (!PS.get().hasPlotArea(l.getWorld())) {
return;
}
Entity victim = event.getEntity();
if (!entityDamage(damager, victim)) {
if (event.isCancelled()) {
if (victim instanceof Ageable) {
Ageable ageable = (Ageable) victim;
if (ageable.getAge() == -24000) {
ageable.setAge(0);
ageable.setAdult();
}
}
}
event.setCancelled(true);
}
}
示例6: applyMountData
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@Override
public void applyMountData(Entity entity) {
super.applyMountData(entity);
if (!(entity instanceof Ageable)) {
return;
}
Ageable ageable = (Ageable) entity;
if (adult) {
ageable.setAdult();
} else {
ageable.setBaby();
}
ageable.setAgeLock(true);
}
示例7: tick
import org.bukkit.entity.Ageable; //导入依赖的package包/类
protected void tick(Block b)
throws Exception
{
for(Iterator iterator = me.mrCookieSlime.Slimefun.holograms.AnimalGrowthAccelerator.getArmorStand(b).getNearbyEntities(3D, 3D, 3D).iterator(); iterator.hasNext();)
{
Entity n = (Entity)iterator.next();
if((n instanceof Ageable) && !((Ageable)n).isAdult())
{
int ai[];
int j = (ai = getInputSlots()).length;
for(int i = 0; i < j; i++)
{
int slot = ai[i];
if(SlimefunManager.isItemSimiliar(BlockStorage.getInventory(b).getItemInSlot(slot), SlimefunItems.ORGANIC_FOOD, false))
{
if(ChargableBlock.getCharge(b) < getEnergyConsumption())
return;
ChargableBlock.addCharge(b, -getEnergyConsumption());
BlockStorage.getInventory(b).replaceExistingItem(slot, InvUtils.decreaseItem(BlockStorage.getInventory(b).getItemInSlot(slot), 1));
((Ageable)n).setAge(((Ageable)n).getAge() + 2000);
if(((Ageable)n).getAge() > 0)
((Ageable)n).setAge(0);
ParticleEffect.VILLAGER_HAPPY.display(((LivingEntity)n).getEyeLocation(), 0.2F, 0.2F, 0.2F, 0.0F, 8);
return;
}
}
}
}
}
示例8: update
import org.bukkit.entity.Ageable; //导入依赖的package包/类
public void update() {
if (entity != null) {
//((CraftEntity) entity).getHandle().setEquipment(4, new net.minecraft.server.v1_5_R2.ItemStack(Item.DIAMOND_HELMET));
//Chat.server(((CraftEntity) entity).getHandle().getEquipment().toString());
Player owner = Bukkit.getPlayerExact(this.owner);
if (owner == null)
return;
entity.setCustomName(nameColor + name);
entity.setCustomNameVisible(true);
if (entity instanceof Tameable) {
tamed = true;
((Tameable) entity).setTamed(true);
((Tameable) entity).setOwner(owner);
}
if (entity instanceof Ageable && age != null) {
if (getAge() == Age.BABY)
((Ageable) entity).setBaby();
((Ageable) entity).setAgeLock(true);
}
if (entity instanceof Zombie && age != null) {
if (getAge() == Age.BABY)
((Zombie) entity).setBaby(true);
}
if (entity instanceof Sheep && color != null) {
((Sheep) entity).setColor(getColor());
}
}
}
示例9: isInstance
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public final boolean isInstance(final @Nullable Entity e) {
if (e == null)
return false;
if (!baby.isUnknown() && e instanceof Ageable && ((Ageable) e).isAdult() != baby.isFalse())
return false;
return getType().isInstance(e) && match((E) e);
}
示例10: isFeedable
import org.bukkit.entity.Ageable; //导入依赖的package包/类
public static boolean isFeedable(Entity n) throws Exception {
if (!(n instanceof org.bukkit.entity.Animals && ((Ageable) n).isAdult() && ((Ageable) n).canBreed())) return false;
Object handle = ReflectionUtils.getHandle(CraftObject.ANIMALS, n);
Field f = ReflectionUtils.tryField(ReflectionUtils.getClass(PackageName.NMS, "EntityAnimal"), "bv", "bw","bx");
f.setAccessible(true);
return f.getInt(handle) < 1;
}
示例11: get
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@Override
@Nullable
protected Boolean[] get(Event e) {
if (entity.getSingle(e) instanceof Ageable) {
if (entity != null) {
return new Boolean[]{((Ageable)entity.getSingle(e)).getAgeLock()};
}
}
return null;
}
示例12: change
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
if (mode == ChangeMode.SET) {
if (entity.getSingle(e) instanceof Ageable) {
if (entity != null) {
((Ageable)entity.getSingle(e)).setAgeLock((Boolean)delta[0]);
}
}
}
}
示例13: get
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@Override
@Nullable
protected Number[] get(Event e) {
if (entity.getSingle(e) instanceof Ageable) {
if (entity != null) {
return new Number[]{((Ageable)entity.getSingle(e)).getAge()};
}
}
return null;
}
示例14: change
import org.bukkit.entity.Ageable; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
if (mode == ChangeMode.SET) {
if (entity.getSingle(e) instanceof Ageable) {
if (entity != null) {
Number age = (Number)delta[0];
((Ageable)entity.getSingle(e)).setAge(age.intValue());
}
}
}
}
示例15: check
import org.bukkit.entity.Ageable; //导入依赖的package包/类
public boolean check(Event e) {
if (entity.getSingle(e) instanceof Ageable) {
if (((Ageable)entity.getSingle(e)).canBreed()) {
return isNegated();
} else {
return !isNegated();
}
}
return false;
}