本文整理汇总了Java中org.bukkit.event.entity.EntityTargetEvent.TargetReason类的典型用法代码示例。如果您正苦于以下问题:Java TargetReason类的具体用法?Java TargetReason怎么用?Java TargetReason使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TargetReason类属于org.bukkit.event.entity.EntityTargetEvent包,在下文中一共展示了TargetReason类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onEntityTarget
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
@EventHandler
public void onEntityTarget(EntityTargetEvent event) {
if (event.getReason() == TargetReason.TARGET_DIED)
return;
PetInstance pet = null;
for (PetInstance p : PetInstance.getList()) {
if (p.getEntity() == null)
continue;
if (p.getEntity().getUniqueId().equals(event.getEntity().getUniqueId())) {
pet = p;
break;
}
}
if (pet != null)
event.setCancelled(true);
}
开发者ID:thekeenant,项目名称:mczone,代码行数:19,代码来源:PetEvents.java
示例2: onTarget
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
public void onTarget(EntityTargetEvent event) {
if (event.isCancelled()) {
return;
}
if ((event.getReason().equals(TargetReason.CLOSEST_PLAYER) ||
event.getReason().equals(TargetReason.OWNER_ATTACKED_TARGET)) &&
(event.getTarget() instanceof Player)) {
double followRange = this.getFollowRange();
double distance = event.getEntity().getLocation().distance(event.getTarget().getLocation());
if ((distance-0.5) <= followRange) {
this.targetName = ((Player)event.getTarget()).getName();
this.lastLocation = event.getEntity().getLocation();
}
} else {
this.targetName = null;
this.lastLocation = null;
}
}
开发者ID:netizen539,项目名称:civcraft,代码行数:21,代码来源:CommonCustomMob.java
示例3: canStart
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected boolean canStart() {
final List<EntityLiving> entities = new ArrayList<EntityLiving>();
for(Class<? extends EntityLiving> targetClass: this.targetClasses) {
if(targetClass==EntityHuman.class) {
this.findNearbyPlayersOptimized(this.entity, entities);
} else {
entities.addAll(NativeInterfaces.WORLD.METHOD_SEARCHENTITIES.invoke(this.entity.world, targetClass, this.entity.boundingBox.grow(this.searchDistance, this.searchDistance/4.0, this.searchDistance), this.entitySelector));
}
}
if(entities.size()>1) Collections.sort(entities, this.comparator);
for(EntityLiving possibleTarget: entities) {
if(this.target(possibleTarget, TargetReason.CLOSEST_PLAYER)) return true;
}
return false;
}
开发者ID:DevCybran,项目名称:Controllable-Mobs-API,代码行数:22,代码来源:PathfinderGoalTargetNearest.java
示例4: onEntityTarget
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEntityTarget(final EntityTargetEvent event)
{
final Entity entity = event.getTarget();
if (entity == null)
{
return;
}
if (entity.getType() == EntityType.PLAYER)
{
final Player user = (Player)event.getTarget();
if ((event.getReason() == TargetReason.CLOSEST_PLAYER || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET
|| event.getReason() == TargetReason.RANDOM_TARGET || event.getReason() == TargetReason.TARGET_ATTACKED_OWNER
|| event.getReason() == TargetReason.OWNER_ATTACKED_TARGET)
&& !prot.getSettings().getData().getPrevent().isEntitytarget() && !Permissions.ENTITY_TARGET_BYPASS.isAuthorized(
user, event.getEntity().getType().getName().toLowerCase()))
{
event.setCancelled(true);
}
}
}
开发者ID:Curtis3321,项目名称:Essentials,代码行数:23,代码来源:EssentialsProtectEntityListener.java
示例5: TNTSheep
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
public TNTSheep(Location location, Player target) {
super(((CraftWorld) location.getWorld()).getHandle());
this.world = location.getWorld();
this.locX = location.getX();
this.locY = location.getY();
this.locZ = location.getZ();
try {
Field b = this.goalSelector.getClass().getDeclaredField("b");
b.setAccessible(true);
Set<?> goals = (Set<?>) b.get(this.goalSelector);
goals.clear(); // Clears the goals
this.getAttributeInstance(GenericAttributes.FOLLOW_RANGE).setValue(128D);
this.getAttributeInstance(GenericAttributes.MOVEMENT_SPEED)
.setValue(
BedwarsRel.getInstance().getConfig().getDouble("specials.tntsheep.speed", 0.4D));
} catch (Exception e) {
BedwarsRel.getInstance().getBugsnag().notify(e);
e.printStackTrace();
}
this.goalSelector.a(0, new PathfinderGoalBedwarsPlayer(this, 1D, false)); // Add bedwars player
// goal
try {
this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()),
TargetReason.TARGET_ATTACKED_ENTITY, false);
} catch (Exception ex) {
// newer spigot builds
if (ex instanceof NoSuchMethodException) {
BedwarsRel.getInstance().getBugsnag().notify(ex);
this.setGoalTarget((EntityLiving) (((CraftPlayer) target).getHandle()));
}
}
((Creature) this.getBukkitEntity()).setTarget((LivingEntity) target);
}
开发者ID:BedwarsRel,项目名称:BedwarsRel,代码行数:41,代码来源:TNTSheep.java
示例6: onTarget
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
@Override
public void onTarget(EntityTargetEvent event) {
super.onTarget(event);
if (event.getReason().equals(TargetReason.FORGOT_TARGET) ||
event.getReason().equals(TargetReason.TARGET_DIED)) {
this.angry = false;
for (Entity e : minions) {
e.getBukkitEntity().remove();
}
}
}
开发者ID:netizen539,项目名称:civcraft,代码行数:15,代码来源:Yobo.java
示例7: onTarget
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
@Override
public void onTarget(EntityTargetEvent event) {
super.onTarget(event);
if (event.getReason().equals(TargetReason.FORGOT_TARGET) ||
event.getReason().equals(TargetReason.TARGET_DIED)) {
event.getEntity().remove();
}
}
开发者ID:netizen539,项目名称:civcraft,代码行数:11,代码来源:AngryYobo.java
示例8: setGoalTarget
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
@Override
public boolean setGoalTarget(EntityLiving entityliving, org.bukkit.event.entity.EntityTargetEvent.TargetReason reason, boolean fire) {
if (!super.setGoalTarget(entityliving, reason, fire)) {
return false;
}
entityliving = getGoalTarget();
if (entityliving == null) {
this.setAngry(false);
} else if (!this.isTamed()) {
this.setAngry(true);
}
return true;
}
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:14,代码来源:EntityWolf.java
示例9: EntityTargetEvent
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
public EntityTargetEvent(Entity entity, Entity target, EntityTargetEvent.TargetReason reason) {
}
开发者ID:deathcap,项目名称:BedrockAPI,代码行数:3,代码来源:EntityTargetEvent.java
示例10: getReason
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
public EntityTargetEvent.TargetReason getReason() {
return null;
}
开发者ID:deathcap,项目名称:BedrockAPI,代码行数:4,代码来源:EntityTargetEvent.java
示例11: EntityTargetLivingEntityEvent
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
public EntityTargetLivingEntityEvent(Entity entity, LivingEntity target, EntityTargetEvent.TargetReason reason) {
super(entity, target, reason);
}
开发者ID:deathcap,项目名称:BedrockAPI,代码行数:4,代码来源:EntityTargetLivingEntityEvent.java
示例12: a
import org.bukkit.event.entity.EntityTargetEvent.TargetReason; //导入依赖的package包/类
public boolean a(EntityHuman entityhuman, EnumHand enumhand, @Nullable ItemStack itemstack) {
if (this.isTamed()) {
if (itemstack != null) {
if (itemstack.getItem() instanceof ItemFood) {
ItemFood itemfood = (ItemFood) itemstack.getItem();
if (itemfood.g() && ((Float) this.datawatcher.get(EntityWolf.DATA_HEALTH)).floatValue() < 20.0F) {
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
}
this.heal((float) itemfood.getNutrition(itemstack), org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.EATING); // CraftBukkit
return true;
}
} else if (itemstack.getItem() == Items.DYE) {
EnumColor enumcolor = EnumColor.fromInvColorIndex(itemstack.getData());
if (enumcolor != this.getCollarColor()) {
this.setCollarColor(enumcolor);
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
}
return true;
}
}
}
if (this.d((EntityLiving) entityhuman) && !this.world.isClientSide && !this.e(itemstack)) {
this.goalSit.setSitting(!this.isSitting());
this.bd = false;
this.navigation.o();
this.setGoalTarget((EntityLiving) null, TargetReason.FORGOT_TARGET, true); // CraftBukkit - reason
}
} else if (itemstack != null && itemstack.getItem() == Items.BONE && !this.isAngry()) {
if (!entityhuman.abilities.canInstantlyBuild) {
--itemstack.count;
}
if (!this.world.isClientSide) {
// CraftBukkit - added event call and isCancelled check.
if (this.random.nextInt(3) == 0 && !CraftEventFactory.callEntityTameEvent(this, entityhuman).isCancelled()) {
this.setTamed(true);
this.navigation.o();
this.setGoalTarget((EntityLiving) null);
this.goalSit.setSitting(true);
this.setHealth(20.0F);
this.setHealth(this.getMaxHealth()); // CraftBukkit - 20.0 -> getMaxHealth()
this.setOwnerUUID(entityhuman.getUniqueID());
this.o(true);
this.world.broadcastEntityEffect(this, (byte) 7);
} else {
this.o(false);
this.world.broadcastEntityEffect(this, (byte) 6);
}
}
return true;
}
return super.a(entityhuman, enumhand, itemstack);
}
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:63,代码来源:EntityWolf.java
注:本文中的org.bukkit.event.entity.EntityTargetEvent.TargetReason类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论