本文整理匯總了Java中net.minecraft.entity.EntityLiving.getEntityWorld方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLiving.getEntityWorld方法的具體用法?Java EntityLiving.getEntityWorld怎麽用?Java EntityLiving.getEntityWorld使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.EntityLiving
的用法示例。
在下文中一共展示了EntityLiving.getEntityWorld方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: throwPearl
import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
public static void throwPearl(EntityLiving entity, EntityLivingBase target) {
World world = entity.getEntityWorld();
EntityEnderPearl pearl = new EntityEnderPearl(world, entity);
double dX = target.posX - entity.posX;
double dY = target.getEntityBoundingBox().minY + (double) (target.height / 3.0F) - pearl.posY;
double dZ = target.posZ - entity.posZ;
double distanceSq = dX * dX + dY * dY + dZ * dZ;
if (distanceSq < 20) {
return;
}
double levelDistance = MathHelper.sqrt(dX * dX + dZ * dZ);
pearl.setThrowableHeading(dX, dY + levelDistance * 0.20000000298023224D, dZ, 1.6F,
(float) (14 - world.getDifficulty().getDifficultyId() * 4));
entity.playSound(SoundEvents.ENTITY_ENDERPEARL_THROW, 1.0F, 1.0F / (world.rand.nextFloat() * 0.4F + 0.8F));
world.spawnEntity(pearl);
}
示例2: spawnBodyGuard
import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
private static void spawnBodyGuard(EntityLiving entity, NemesisEntry nemesis) {
// TODO use nemesis colors
int count = 3 + nemesis.getLevel() * 3;
for (int i = 0; i < count; i++) {
EntityCreature bodyGuard = new EntityZombie(entity.getEntityWorld());
bodyGuard.addTag(NemesisSystem.TAG_BODY_GUARD);
bodyGuard.getEntityData().setUniqueId(NemesisSystem.NBT_NEMESIS_ID, nemesis.getId());
equipBodyGuard(bodyGuard);
SpawnApi.spawnEntityCreature(entity.getEntityWorld(), bodyGuard, entity.getPosition(), 10);
BehaviorApi.setFollowSpeed(bodyGuard, 1.5);
}
}
示例3: onTeleportEntityHarm
import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
@SubscribeEvent
public void onTeleportEntityHarm(LivingHurtEvent event) {
if (!(event.getEntityLiving() instanceof EntityLiving) || !event.getEntityLiving().getTags().contains(NemesisSystem.TAG_NEMESIS)) {
return;
}
EntityLiving entity = (EntityLiving) event.getEntityLiving();
NemesisEntry nemesis = NemesisUtil.loadNemesisFromEntity(entity);
if (nemesis == null) {
return;
}
if (!nemesis.hasTrait(Type.TELEPORT)) {
return;
}
World world = entity.getEntityWorld();
if (world.rand.nextInt(2) != 0) {
return;
}
List<EntityCreature> guards = NemesisUtil.findNemesisBodyGuards(world, nemesis.getId(), entity.getPosition());
if (guards.size() < 1) {
return;
}
EntityCreature teleportTarget = guards.get(world.rand.nextInt(guards.size()));
NemesisActions.throwPearl(entity, teleportTarget);
}