本文整理汇总了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;
}