Java Code Examples for net.minecraft.entity.Entity#isEntityAlive()

The following examples show how to use net.minecraft.entity.Entity#isEntityAlive() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ThermiteTeleportationHandler.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static void transferEntityToWorld(Entity ent, WorldServer oldWorld, WorldServer newWorld) {

		WorldProvider pOld = oldWorld.provider;
		WorldProvider pNew = newWorld.provider;
		double moveFactor = pOld.getMovementFactor() / pNew.getMovementFactor();
		double x = ent.posX * moveFactor;
		double z = ent.posZ * moveFactor;
		x = MathHelper.clamp_double(x, -29999872, 29999872);
		z = MathHelper.clamp_double(z, -29999872, 29999872);

		if (ent.isEntityAlive()) {
			ent.setLocationAndAngles(x, ent.posY, z, ent.rotationYaw, ent.rotationPitch);
			newWorld.spawnEntityInWorld(ent);
			newWorld.updateEntityWithOptionalForce(ent, false);
		}

		ent.setWorld(newWorld);
	}
 
Example 2
Source File: ClientProxy.java    From NBTEdit with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void renderWorldLast(RenderWorldLastEvent event){
	GuiScreen curScreen = Minecraft.getMinecraft().currentScreen;
	if (curScreen instanceof GuiEditNBTTree){
		GuiEditNBTTree screen = (GuiEditNBTTree)curScreen;
		Entity e = screen.getEntity();
		
		if (e != null && e.isEntityAlive())
			drawBoundingBox(event.context, event.partialTicks,e.boundingBox);
		else if (screen.isTileEntity()){
			int x = screen.getBlockX();
			int y = screen.y;
			int z = screen.z;
			World world = Minecraft.getMinecraft().theWorld;
			Block b = world.getBlock(x, y, z);
			if (b != null) {
				b.setBlockBoundsBasedOnState(world, x,y,z);
				drawBoundingBox(event.context,event.partialTicks, b.getSelectedBoundingBoxFromPool(world,x, y,z));
			}
		}
	}
}
 
Example 3
Source File: EntityUtils.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
public static boolean isSelected(final Entity entity, final boolean canAttackCheck) {
    if(entity instanceof EntityLivingBase && (targetDead || entity.isEntityAlive()) && entity != mc.thePlayer) {
        if(targetInvisible || !entity.isInvisible()) {
            if(targetPlayer && entity instanceof EntityPlayer) {
                final EntityPlayer entityPlayer = (EntityPlayer) entity;

                if(canAttackCheck) {
                    if(AntiBot.isBot(entityPlayer))
                        return false;

                    if (isFriend(entityPlayer) && !LiquidBounce.moduleManager.getModule(NoFriends.class).getState())
                        return false;

                    if(entityPlayer.isSpectator())
                        return false;

                    final Teams teams = (Teams) LiquidBounce.moduleManager.getModule(Teams.class);
                    return !teams.getState() || !teams.isInYourTeam(entityPlayer);
                }

                return true;
            }

            return targetMobs && isMob(entity) || targetAnimals && isAnimal(entity);

        }
    }
    return false;
}
 
Example 4
Source File: TeleporterNoPortal.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void teleport(Entity entity, WorldServer world) {

		if (entity.isEntityAlive()) {
			entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
			world.spawnEntity(entity);
			world.updateEntityWithOptionalForce(entity, false);
		}
		entity.setWorld(world);
	}
 
Example 5
Source File: TeleporterNoPortalSeekBlock.java    From AdvancedRocketry with MIT License 5 votes vote down vote up
public void teleport(Entity entity, WorldServer world) {

		if (entity.isEntityAlive()) {
			entity.setLocationAndAngles(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
			world.spawnEntity(entity);
			world.updateEntityWithOptionalForce(entity, false);
		}
		entity.setWorld(world);
	}
 
Example 6
Source File: TeleportEntity.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private static Entity teleportEntity(Entity entity, double x, double y, double z, int dimDst, boolean forceRecreate)
{
    if (entity == null || entity.isEntityAlive() == false || canTeleportEntity(entity) == false || entity.getEntityWorld().isRemote)
    {
        return null;
    }

    // Post the event and check if the teleport should be allowed
    if (entity instanceof EntityLivingBase)
    {
        EnderTeleportEvent event = new EnderTeleportEvent((EntityLivingBase) entity, x, y, z, 0.0f);

        if (MinecraftForge.EVENT_BUS.post(event))
        {
            return null;
        }
    }

    // Sound and particles on the original location
    addTeleportSoundsAndParticles(entity.getEntityWorld(), entity.posX, entity.posY, entity.posZ);

    if (entity instanceof EntityLiving)
    {
        ((EntityLiving) entity).setMoveForward(0.0f);
        ((EntityLiving) entity).getNavigator().clearPath();
    }

    if (entity.getEntityWorld().provider.getDimension() != dimDst)
    {
        entity = teleportEntityToDimension(entity, x, y, z, dimDst);
    }
    else
    {
        entity = teleportEntityInsideSameDimension(entity, x, y, z);
    }

    if (entity != null)
    {
        // Final position
        addTeleportSoundsAndParticles(entity.getEntityWorld(), x, y, z);
    }

    return entity;
}