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


Java Ageable类代码示例

本文整理汇总了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);
			}
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:19,代码来源:EffBabyAdult.java

示例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;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:17,代码来源:CondIsAdult.java

示例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);
}
 
开发者ID:stefvanschie,项目名称:buildinggame,代码行数:27,代码来源:BabyMenu.java

示例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;
				}
			}
		}
	}
}
 
开发者ID:TheBusyBiscuit,项目名称:Slimefun4,代码行数:18,代码来源:AnimalGrowthAccelerator.java

示例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);
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:22,代码来源:PlayerEvents.java

示例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);
}
 
开发者ID:CodingBadgers,项目名称:MineKart,代码行数:19,代码来源:AgeableMountData.java

示例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;
                }
            }

        }
    }

}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:32,代码来源:AnimalGrowthAccelerator.java

示例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());
        }
	}
}
 
开发者ID:thekeenant,项目名称:mczone,代码行数:29,代码来源:PetInstance.java

示例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);
}
 
开发者ID:nfell2009,项目名称:Skript,代码行数:9,代码来源:EntityData.java

示例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;
}
 
开发者ID:TheBusyBiscuit,项目名称:CS-CoreLib,代码行数:9,代码来源:Animals.java

示例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;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:ExprAgeLock.java

示例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]);
			}
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:ExprAgeLock.java

示例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;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:ExprAge.java

示例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());
			}
		}
	}
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:12,代码来源:ExprAge.java

示例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;
}
 
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:CondCanBreed.java


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