本文整理匯總了Java中org.spongepowered.api.entity.Entity.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java Entity.getType方法的具體用法?Java Entity.getType怎麽用?Java Entity.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.spongepowered.api.entity.Entity
的用法示例。
在下文中一共展示了Entity.getType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CachedEntity
import org.spongepowered.api.entity.Entity; //導入方法依賴的package包/類
public CachedEntity(Entity entity) {
super(entity);
this.type = new CachedCatalogType(entity.getType());
this.uuid = UUID.fromString(entity.getUniqueId().toString());
this.location = new CachedLocation(entity.getLocation());
this.rotation = entity.getRotation().clone();
this.velocity = entity.getVelocity().clone();
this.scale = entity.getScale().clone();
if (entity instanceof Carrier) {
try {
this.inventory = new CachedInventory(((Carrier) entity).getInventory());
} catch (AbstractMethodError ignored) {}
}
}
示例2: onSpawnExp
import org.spongepowered.api.entity.Entity; //導入方法依賴的package包/類
@Listener
public void onSpawnExp(final SpawnEntityEvent event, @First Player player) {
if (this.stopThem.contains(player.getUniqueId())) {
for (Entity e : event.getEntities()) {
if (e.getType() == EntityTypes.EXPERIENCE_ORB) {
event.setCancelled(true);
return;
}
}
}
}
示例3: onDamageEntity
import org.spongepowered.api.entity.Entity; //導入方法依賴的package包/類
@Listener
public void onDamageEntity(DamageEntityEvent event, @First EntityDamageSource source) {
// Optional<IndirectEntityDamageSource> secondSource = event.getCause().first(IndirectEntityDamageSource.class);
ConfigurationNode node = PlayerList.getInstance().getNode();
Entity entityTarget = event.getTargetEntity();
if (source.getSource().getType() == EntityTypes.PLAYER || (source.getSource().getType() == EntityTypes.ARROW
&& event.getCause().first(IndirectEntityDamageSource.class).get().getIndirectSource().getType() == EntityTypes.PLAYER)) {
Player cause = null;
if (source.getSource().getType() == EntityTypes.PLAYER) {
cause = (Player) source.getSource();
} else {
cause = (Player) event.getCause().first(IndirectEntityDamageSource.class).get().getIndirectSource();
}
if (!node.getNode("players", cause.getUniqueId(), "pvp").getBoolean()) {
if (entityTarget.getType() == EntityTypes.PLAYER) {
event.setCancelled(true);
cause.sendMessage(TranslationHelper.t("text.player.attacker", cause.getLocale()));
cause.sendMessage(TranslationHelper.t("text.player.toggle", cause.getLocale()));
return;
}
} else if (entityTarget.getType() == EntityTypes.PLAYER) {
Player target = (Player) entityTarget;
if (!node.getNode("players", target.getUniqueId(), "pvp").getBoolean()) {
event.setCancelled(true);
cause.sendMessage(TranslationHelper.t("text.player.target", cause.getLocale()));
target.sendMessage(TranslationHelper.t("text.player.attacked", cause.getLocale()));
return;
}
}
}
}
示例4: setTypeAndData
import org.spongepowered.api.entity.Entity; //導入方法依賴的package包/類
@Override
public void setTypeAndData(Entity entity) {
this.spongeType = entity.getType();
updateType(entity, entity.getType());
}