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));
}
}
}
}
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;
}
}
}
}
}
}
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);
}
}
}
}
}
}
Aggregations