當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。