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


Java Entity.getType方法代码示例

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


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

示例1: PlaceCheckDoor

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
 public void PlaceCheckDoor(BlockPlaceEvent e) {
     if(ConfigPatch.AntiInfSuagrenable){
if(e.isCancelled()){
	Player p = e.getPlayer();
             List<Entity> entities = p.getNearbyEntities(2, 2, 2);
             for(int i=0;i<entities.size();i++){
                 Entity ent = entities.get(i);
                 if(ent.getType() == EntityType.DROPPED_ITEM){
                     Item item = (Item)ent;
                     if(item.getItemStack().getType() == Material.SUGAR_CANE||item.getItemStack().getType() == Material.CACTUS){
                         ent.remove();
                     }
                 }
             }
}
     }
 }
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:19,代码来源:AntiInfSuagr.java

示例2: CheckCrowd

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void CheckCrowd(ChunkLoadEvent evt) {
	if (ConfigOptimize.NoCrowdedEntityenable) {
		Chunk chunk = evt.getChunk();
		Entity[] entities = chunk.getEntities();

		for (Entity e : entities) {
			EntityType type = e.getType();
			int count = 0;
			if (ConfigOptimize.NoCrowdedEntityTypeList.contains("*")
					|| ConfigOptimize.NoCrowdedEntityTypeList.contains(type.name())) {
				count++;
				if (count > ConfigOptimize.NoCrowdedEntityPerChunkLimit && e.getType() != EntityType.PLAYER) {
					e.remove();
				}
			}
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:20,代码来源:NoCrowdEntity.java

示例3: getNearbyEntities

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static List<Entity> getNearbyEntities(Location center, double radius, EntityType filter)
{
    double chunkRadius = radius < 16 ? 1 : (radius - (radius % 16)) / 16;
    List<Entity> entities = new ArrayList<>();

    for (double chX = 0 - chunkRadius; chX <= chunkRadius; chX++)
    {
        for (double chZ = 0 - chunkRadius; chZ <= chunkRadius; chZ++)
        {
            double x = center.getX();
            double y = center.getY();
            double z = center.getZ();

            for (Entity entity : new Location(center.getWorld(), x + (chX * 16), y, z + (chZ * 16)).getChunk().getEntities())
            {
                if (filter != null && entity.getType() != filter)
                    continue;

                if (entity.getLocation().distance(center) <= radius && entity.getLocation().getBlock() != center.getBlock())
                    entities.add(entity);
            }
        }
    }

    return entities;
}
 
开发者ID:SamaGames,项目名称:SamaGamesAPI,代码行数:27,代码来源:ProximityUtils.java

示例4: onPacketReceiving

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void onPacketReceiving(PacketEvent packetEvent) {
    Player p = packetEvent.getPlayer();
    PacketContainer packet = packetEvent.getPacket();
    if (packet.getType().equals(PacketType.Play.Client.USE_ENTITY)) {
        UUID u = tagMap.get(packet.getIntegers().read(0));
        if (u == null) return;
        Entity e = p.getNearbyEntities(8, 8, 8).stream().filter(entity -> entity.getUniqueId().equals(u)).findAny
                ().orElse(null);
        if (e == null) return;
        if (!HitboxUtil.isLookingAt(p, e)) return;
        packet.getIntegers().write(0, e.getEntityId());
        if (e.getType() == EntityType.ARMOR_STAND)
            packet.getEntityUseActions().write(0, EnumWrappers.EntityUseAction.ATTACK);
    }
}
 
开发者ID:iso2013,项目名称:MultiLineAPI,代码行数:17,代码来源:PacketListener.java

示例5: ChunkloadClear

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void ChunkloadClear(ChunkUnloadEvent event) {
	if (ConfigOptimize.UnloadClearenable != true) {
		return;
	}
	Chunk chunk = event.getChunk();
	boolean noclearitemchunk = false;
	int dcs = DeathChunk.size();
	for (int i = 0; i < dcs; i++) {
		Chunk deathchunk = DeathChunk.get(i);
		if (Utils.isSameChunk(chunk, deathchunk)) {
			DeathChunk.remove(chunk);
			noclearitemchunk = true;
			break;
		}
	}
	Entity[] entities = chunk.getEntities();
	for (int i = 0; i < entities.length; i++) {
		Entity ent = entities[i];
		if (ent.getType() == EntityType.DROPPED_ITEM && noclearitemchunk == false && ConfigOptimize.UnloadClearDROPPED_ITEMenable) {
			ent.remove();
		}
		if(ConfigOptimize.UnloadCleartype.contains(ent.getType().name())||ConfigOptimize.UnloadCleartype.contains("*")) {
			ent.remove();
		}
	}
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:28,代码来源:UnloadClear.java

示例6: EntityInfo

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public EntityInfo(Entity entity, @Nullable ParticipantState owner) {
    super(owner);
    this.entityType = entity.getType();
    this.entityClass = entity.getClass();
    this.customName = entity.getCustomName();
    this.nameKey = NMSHacks.getTranslationKey(entity);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:8,代码来源:EntityInfo.java

示例7: isPigZombie

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean isPigZombie(Entity e){
    return e.getType() == EntityType.PIG_ZOMBIE;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:MobUtils.java

示例8: isZombieVillager

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean isZombieVillager(Entity e){
    return e.getType() == EntityType.ZOMBIE_VILLAGER;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:MobUtils.java

示例9: change

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void change(Event e, Object[] delta, @NotNull Changer.ChangeMode mode) {
	Entity ent = entity.getSingle(e);
	if (ent == null) {
		return;
	}
	if (PotionUtils.isEntityThrownPotion(ent)) {
		ItemStack item = ((ThrownPotion) ent).getItem();
		PotionMeta potionMeta = ((PotionMeta) ((ThrownPotion) ent).getItem().getItemMeta());
		switch (mode) {
			case ADD:
				Arrays.asList((PotionEffect[]) delta).forEach(eff -> potionMeta.addCustomEffect(eff, true));
				break;
			case SET:
				potionMeta.clearCustomEffects();
				Arrays.asList((PotionEffect[]) delta).forEach(eff -> potionMeta.addCustomEffect(eff, true));
				break;
			case REMOVE:
				potionMeta.removeCustomEffect((PotionEffectType) delta[0]);
				break;
			case DELETE:
				potionMeta.clearCustomEffects();
				break;
		}
		item.setItemMeta(potionMeta);
		((ThrownPotion) ent).setItem(item);
	} else if (ent.getType() == EntityType.TIPPED_ARROW) {
		TippedArrow tippedArrow = (TippedArrow) ent;
		switch (mode) {
			case ADD:
				Arrays.asList(((PotionEffect[]) delta)).forEach(eff -> tippedArrow.addCustomEffect(eff, true));
				break;
			case SET:
				tippedArrow.clearCustomEffects();
				Arrays.asList(((PotionEffect[]) delta)).forEach(eff -> tippedArrow.addCustomEffect(eff, true));
				break;
			case REMOVE:
				tippedArrow.removeCustomEffect((PotionEffectType) delta[0]);
				break;
			case DELETE:
				tippedArrow.clearCustomEffects();
				break;
		}
	}
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:46,代码来源:SExprThrownPotionEffects.java

示例10: isEntityThrownPotion

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static boolean isEntityThrownPotion(@NotNull Entity entity) {
	return entity.getType() == EntityType.SPLASH_POTION || entity.getType() == EntityType.LINGERING_POTION;
}
 
开发者ID:Syst3ms,项目名称:QuarSK,代码行数:4,代码来源:PotionUtils.java

示例11: isCreeper

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean isCreeper(Entity e){
    return e.getType() == EntityType.CREEPER;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:MobUtils.java

示例12: isSheep

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean isSheep(Entity e){
    return e.getType() == EntityType.SHEEP;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:MobUtils.java

示例13: isVillager

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean isVillager(Entity e){
    return e.getType() == EntityType.VILLAGER;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:MobUtils.java

示例14: isHorse

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean isHorse(Entity e) {
    return e.getType() == EntityType.HORSE;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:MobUtils.java

示例15: isDonkey

import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public boolean isDonkey(Entity e){
    return e.getType() == EntityType.DONKEY;
}
 
开发者ID:cadox8,项目名称:PA,代码行数:4,代码来源:MobUtils.java


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