Search in sources :

Example 1 with IMeteorType

use of stevekung.mods.moreplanets.world.IMeteorType in project MorePlanets by SteveKunG.

the class EntityEventHandler method onLivingUpdate.

@SubscribeEvent
public void onLivingUpdate(LivingUpdateEvent event) {
    EntityLivingBase living = event.getEntityLiving();
    World world = living.world;
    if (living.isDead) {
        int id = GCCoreUtil.getDimensionID(living.world);
        PacketSimpleMP.sendToAllAround(new PacketSimpleMP(EnumSimplePacketMP.C_REMOVE_ENTITY_ID, id, String.valueOf(living.getEntityId())), living.world, id, living.getPosition(), 64);
    }
    if (living instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) living;
        if (ConfigManagerMP.enableStartedPlanet && !WorldTickEventHandler.startedDimensionData.startedDimension && !(ConfigManagerMP.startedPlanet.equals("planet.") || ConfigManagerMP.startedPlanet.equals("moon.") || ConfigManagerMP.startedPlanet.equals("satellite."))) {
            MPLog.debug("Start teleporting player to dimension {}", ConfigManagerMP.startedPlanet);
            TeleportUtil.startNewDimension(player);
            WorldTickEventHandler.startedDimensionData.startedDimension = true;
            WorldTickEventHandler.startedDimensionData.planetToBack = ConfigManagerMP.startedPlanet;
            WorldTickEventHandler.startedDimensionData.setDirty(true);
        }
        if (player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) || this.isInOxygen(world, player)) {
            player.removePotionEffect(MPPotions.INFECTED_SPORE);
        }
        if (player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
            player.removePotionEffect(MPPotions.DARK_ENERGY);
        }
        if (world.provider instanceof WorldProviderNibiru) {
            if (world.isRainingAt(player.getPosition()) && !this.isGodPlayer(player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
                player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
            }
            if (player.ticksExisted % 128 == 0 && !this.isGodPlayer(player) && !this.isInOxygen(world, player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && world.getBiome(player.getPosition()) != MPBiomes.GREEN_VEIN) {
                player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
            }
        }
        if (world.provider instanceof IMeteorType) {
        // this.spawnMeteor(world, player, (IMeteorType)world.provider);
        }
    }
    if (world.provider instanceof WorldProviderNibiru) {
        if (!(living instanceof EntityPlayer) && !EntityEffectHelper.isGalacticraftMob(living) && !(living instanceof EntityJuicer)) {
            if (living.ticksExisted % 128 == 0 && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
            }
            if (world.isRainingAt(living.getPosition()) && world.getBiome(living.getPosition()) != MPBiomes.GREEN_VEIN) {
                living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
            }
        }
    }
}
Also used : WorldProviderNibiru(stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru) PotionEffect(net.minecraft.potion.PotionEffect) EntityJuicer(micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PacketSimpleMP(stevekung.mods.moreplanets.network.PacketSimpleMP) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) World(net.minecraft.world.World) IMeteorType(stevekung.mods.moreplanets.world.IMeteorType) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with IMeteorType

use of stevekung.mods.moreplanets.world.IMeteorType in project MorePlanets by SteveKunG.

the class EntityEventHandler method onLivingUpdate.

@SubscribeEvent
public void onLivingUpdate(LivingEvent.LivingUpdateEvent event) {
    EntityLivingBase living = event.getEntityLiving();
    World world = living.world;
    if (living instanceof EntityPlayerMP) {
        EntityPlayerMP player = (EntityPlayerMP) living;
        if (player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) || this.isInOxygen(world, player)) {
            player.removePotionEffect(MPPotions.INFECTED_SPORE);
        }
        if (player.isPotionActive(MPPotions.DARK_ENERGY_PROTECTION)) {
            player.removePotionEffect(MPPotions.DARK_ENERGY);
        }
        if (world.provider instanceof WorldProviderNibiru) {
            if (!this.isGodPlayer(player) && !player.isPotionActive(MPPotions.INFECTED_SPORE_PROTECTION) && !(world.getBiome(player.getPosition()) instanceof BiomeGreenVeinFields)) {
                if (world.isRainingAt(player.getPosition())) {
                    player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
                }
                if (player.ticksExisted % 128 == 0 && !this.isInOxygen(world, player)) {
                    player.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
                }
            }
        }
        if (!world.isRemote && world.provider instanceof IMeteorType) {
            this.spawnMeteors(world, player, (IMeteorType) world.provider);
        }
    } else {
        if (ConfigManagerMP.moreplanets_planet_settings.enableInfectedSporeForMobs && world.provider instanceof WorldProviderNibiru) {
            if (!EntityEffectUtils.isGalacticraftMob(living) && !(living instanceof EntityJuicer) && !(world.getBiome(living.getPosition()) instanceof BiomeGreenVeinFields)) {
                if (living.ticksExisted % 128 == 0) {
                    living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 80));
                } else if (world.isRainingAt(living.getPosition())) {
                    living.addPotionEffect(new PotionEffect(MPPotions.INFECTED_SPORE, 40));
                }
            }
        }
    }
    if (living instanceof IMob) {
        for (BlockVec3Dim vec : TileEntityShieldGenerator.LOADED_GENERATORS) {
            if (vec != null && vec.dim == GCCoreUtil.getDimensionID(world)) {
                TileEntity tile = vec.getTileEntity();
                if (tile instanceof TileEntityShieldGenerator) {
                    TileEntityShieldGenerator shield = (TileEntityShieldGenerator) tile;
                    if (!living.world.isRemote && !living.isDead && shield.isInsideShield(living.getPosition()) && !shield.disabled && shield.enableShield && shield.shieldCapacity > 0) {
                        if (!shield.enableDamage) {
                            double d4 = living.getDistance(tile.getPos().getX(), tile.getPos().getY(), tile.getPos().getZ());
                            double d6 = living.posX - tile.getPos().getX();
                            double d8 = living.posY - tile.getPos().getY();
                            double d10 = living.posZ - tile.getPos().getZ();
                            double d11 = MathHelper.sqrt(d6 * d6 + d8 * d8 + d10 * d10);
                            d6 /= d11;
                            d8 /= d11;
                            d10 /= d11;
                            double d13 = (0.0D - d4) * 2.0D / 10.0D;
                            double d14 = d13;
                            double knockback = 10.0D;
                            living.motionX -= d6 * d14 / knockback;
                            living.motionY -= d8 * d14 / knockback;
                            living.motionZ -= d10 * d14 / knockback;
                        }
                        UUID uuid;
                        try {
                            uuid = UUID.fromString(shield.ownerUUID);
                        } catch (Exception e) {
                            // default uuid :)
                            uuid = UUID.fromString("eef3a603-1c1b-4c98-8264-d2f04b231ef4");
                        }
                        if (living.world.getPlayerEntityByUUID(uuid) != null) {
                            if (living.ticksExisted % 8 == 0) {
                                ((WorldServer) living.world).spawnParticle(EnumParticleTypes.CRIT_MAGIC, living.posX, living.posY, living.posZ, 20, 0.0D, 0.5D, 0.0D, 1.0D);
                            }
                            if (shield.enableDamage) {
                                living.attackEntityFrom(DamageSource.causePlayerDamage(living.world.getPlayerEntityByUUID(uuid)), shield.shieldDamage);
                            }
                        } else {
                            if (living.ticksExisted % 8 == 0) {
                                ((WorldServer) living.world).spawnParticle(EnumParticleTypes.CRIT_MAGIC, living.posX, living.posY, living.posZ, 20, 0.0D, 0.5D, 0.0D, 1.0D);
                            }
                            if (shield.enableDamage) {
                                living.attackEntityFrom(DamageSource.GENERIC, shield.shieldDamage);
                            }
                        }
                        float motion = MathHelper.sqrt(living.motionX * living.motionX + living.motionZ * living.motionZ);
                        shield.shieldCapacity -= motion * 2;
                    }
                }
            }
        }
    }
}
Also used : WorldProviderNibiru(stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru) PotionEffect(net.minecraft.potion.PotionEffect) WorldServer(net.minecraft.world.WorldServer) World(net.minecraft.world.World) IMeteorType(stevekung.mods.moreplanets.world.IMeteorType) BlockVec3Dim(micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim) TileEntity(net.minecraft.tileentity.TileEntity) IMob(net.minecraft.entity.monster.IMob) BiomeGreenVeinFields(stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeGreenVeinFields) EntityJuicer(micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer) TileEntityShieldGenerator(stevekung.mods.moreplanets.tileentity.TileEntityShieldGenerator) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) UUID(java.util.UUID) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with IMeteorType

use of stevekung.mods.moreplanets.world.IMeteorType in project MorePlanets by SteveKunG.

the class EntityEventHandler method spawnMeteor.

public void spawnMeteor(World world, EntityPlayerMP player, IMeteorType meteor) {
    Entity meteorEntity = null;
    if (FMLCommonHandler.instance().getEffectiveSide() != Side.CLIENT) {
        if (((IMeteorType) world.provider).getMeteorSpawnFrequency() > 0.0D && meteor.getMeteorType() != null) {
            int f = (int) (((IMeteorType) world.provider).getMeteorSpawnFrequency() * 750D);
            int r = ((WorldServer) world).getMinecraftServer().getPlayerList().getViewDistance();
            int x, z;
            double motX, motZ;
            x = world.rand.nextInt(20) + 160;
            z = world.rand.nextInt(20) - 10;
            motX = world.rand.nextDouble() * 2 - 2.5D;
            motZ = world.rand.nextDouble() * 5 - 2.5D;
            int px = MathHelper.floor(player.posX);
            if (world.rand.nextInt(f) == 0) {
                EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100);
                if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) {
                    if ((x + px >> 4) - (px >> 4) >= r) {
                        x = ((px >> 4) + r << 4) - 1 - px;
                    }
                    switch(meteor.getMeteorType()) {
                        case ANTAROS:
                            // TODO
                            meteorEntity = new EntityMeteor(world, player.posX + x, 355.0D, player.posZ + z, motX - 2.5D, 0, motZ - 2.5D, 1);
                            break;
                    }
                    if (!world.isRemote) {
                        world.spawnEntity(meteorEntity);
                        MPLog.debug("Spawn {} at {} {} {}", meteor.getClass().getSimpleName(), (int) meteorEntity.posX, (int) meteorEntity.posY, (int) meteorEntity.posZ);
                    }
                }
            }
            if (world.rand.nextInt(f * 3) == 0) {
                EntityPlayer closestPlayer = world.getClosestPlayerToEntity(player, 100);
                if (closestPlayer == null || closestPlayer.getEntityId() <= player.getEntityId()) {
                    switch(meteor.getMeteorType()) {
                        case ANTAROS:
                            // TODO
                            meteorEntity = new EntityMeteor(world, player.posX + x, 355.0D, player.posZ + z, motX - 2.5D, 0, motZ - 2.5D, 1);
                            break;
                    }
                    if (!world.isRemote) {
                        world.spawnEntity(meteorEntity);
                        MPLog.debug("Spawn {} at {} {} {}", meteor.getClass().getSimpleName(), (int) meteorEntity.posX, (int) meteorEntity.posY, (int) meteorEntity.posZ);
                    }
                }
            }
        }
    }
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayer(net.minecraft.entity.player.EntityPlayer) WorldServer(net.minecraft.world.WorldServer) EntityMeteor(micdoodle8.mods.galacticraft.core.entities.EntityMeteor) IMeteorType(stevekung.mods.moreplanets.world.IMeteorType)

Aggregations

IMeteorType (stevekung.mods.moreplanets.world.IMeteorType)3 EntityJuicer (micdoodle8.mods.galacticraft.planets.venus.entities.EntityJuicer)2 EntityLivingBase (net.minecraft.entity.EntityLivingBase)2 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 PotionEffect (net.minecraft.potion.PotionEffect)2 World (net.minecraft.world.World)2 WorldServer (net.minecraft.world.WorldServer)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 UUID (java.util.UUID)1 BlockVec3Dim (micdoodle8.mods.galacticraft.api.vector.BlockVec3Dim)1 EntityMeteor (micdoodle8.mods.galacticraft.core.entities.EntityMeteor)1 Entity (net.minecraft.entity.Entity)1 IMob (net.minecraft.entity.monster.IMob)1 TileEntity (net.minecraft.tileentity.TileEntity)1 WorldProviderNibiru (stevekung.mods.moreplanets.module.planets.nibiru.dimension.WorldProviderNibiru)1 PacketSimpleMP (stevekung.mods.moreplanets.network.PacketSimpleMP)1 WorldProviderNibiru (stevekung.mods.moreplanets.planets.nibiru.dimension.WorldProviderNibiru)1 BiomeGreenVeinFields (stevekung.mods.moreplanets.planets.nibiru.world.gen.biome.BiomeGreenVeinFields)1 TileEntityShieldGenerator (stevekung.mods.moreplanets.tileentity.TileEntityShieldGenerator)1