Search in sources :

Example 1 with EntitySmallAsteroid

use of micdoodle8.mods.galacticraft.planets.asteroids.entities.EntitySmallAsteroid in project Galacticraft by micdoodle8.

the class AsteroidsPlayerHandler method onPlayerUpdate.

public void onPlayerUpdate(EntityPlayerMP player) {
    if (!player.worldObj.isRemote && player.worldObj.provider instanceof WorldProviderAsteroids) {
        final int f = 50;
        if (player.worldObj.rand.nextInt(f) == 0 && player.posY < 260D) {
            final EntityPlayer closestPlayer = player.worldObj.getClosestPlayerToEntity(player, 100);
            if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) {
                double x, y, z;
                double motX, motY, motZ;
                double r = player.worldObj.rand.nextInt(60) + 30D;
                double theta = Math.PI * 2.0 * player.worldObj.rand.nextDouble();
                x = player.posX + Math.cos(theta) * r;
                y = player.posY + player.worldObj.rand.nextInt(5);
                z = player.posZ + Math.sin(theta) * r;
                motX = (player.posX - x + (player.worldObj.rand.nextDouble() - 0.5) * 40) / 400.0F;
                motY = (player.worldObj.rand.nextDouble() - 0.5) * 0.4;
                motZ = (player.posZ - z + (player.worldObj.rand.nextDouble() - 0.5) * 40) / 400.0F;
                final EntitySmallAsteroid smallAsteroid = new EntitySmallAsteroid(player.worldObj);
                smallAsteroid.setPosition(x, y, z);
                smallAsteroid.motionX = motX;
                smallAsteroid.motionY = motY;
                smallAsteroid.motionZ = motZ;
                smallAsteroid.spinYaw = player.worldObj.rand.nextFloat() * 4;
                smallAsteroid.spinPitch = player.worldObj.rand.nextFloat() * 2;
                player.worldObj.spawnEntityInWorld(smallAsteroid);
            }
        }
    }
}
Also used : EntitySmallAsteroid(micdoodle8.mods.galacticraft.planets.asteroids.entities.EntitySmallAsteroid) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldProviderAsteroids(micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids)

Aggregations

WorldProviderAsteroids (micdoodle8.mods.galacticraft.planets.asteroids.dimension.WorldProviderAsteroids)1 EntitySmallAsteroid (micdoodle8.mods.galacticraft.planets.asteroids.entities.EntitySmallAsteroid)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1