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