本文整理匯總了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();
}
}
}
}
}
}
示例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();
}
}
}
}
}
示例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;
}
示例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);
}
}
示例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();
}
}
}
示例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);
}
示例7: isPigZombie
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isPigZombie(Entity e){
return e.getType() == EntityType.PIG_ZOMBIE;
}
示例8: isZombieVillager
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isZombieVillager(Entity e){
return e.getType() == EntityType.ZOMBIE_VILLAGER;
}
示例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;
}
}
}
示例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;
}
示例11: isCreeper
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isCreeper(Entity e){
return e.getType() == EntityType.CREEPER;
}
示例12: isSheep
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isSheep(Entity e){
return e.getType() == EntityType.SHEEP;
}
示例13: isVillager
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isVillager(Entity e){
return e.getType() == EntityType.VILLAGER;
}
示例14: isHorse
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isHorse(Entity e) {
return e.getType() == EntityType.HORSE;
}
示例15: isDonkey
import org.bukkit.entity.Entity; //導入方法依賴的package包/類
public boolean isDonkey(Entity e){
return e.getType() == EntityType.DONKEY;
}