Search in sources :

Example 11 with AMDataWriter

use of am2.network.AMDataWriter in project ArsMagica2 by Mithion.

the class AMPacketProcessorClient method handleSyncBetaParticles.

private void handleSyncBetaParticles(byte[] data) {
    EntityPlayer localPlayer = Minecraft.getMinecraft().thePlayer;
    if (!AMCore.proxy.playerTracker.hasAA(localPlayer))
        return;
    ExtendedProperties e = ExtendedProperties.For(localPlayer);
    AMDataWriter writer = new AMDataWriter();
    writer.add(e.getAuraIndex());
    writer.add(e.getAuraBehaviour());
    writer.add(e.getAuraScale());
    writer.add(e.getAuraAlpha());
    writer.add(e.getAuraColorRandomize());
    writer.add(e.getAuraColorDefault());
    writer.add(e.getAuraColor());
    writer.add(e.getAuraDelay());
    writer.add(e.getAuraQuantity());
    writer.add(e.getAuraSpeed());
    AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.SYNC_BETA_PARTICLES, writer.generate());
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 12 with AMDataWriter

use of am2.network.AMDataWriter in project ArsMagica2 by Mithion.

the class ParticleManagerServer method RibbonFromEntityToEntity.

public void RibbonFromEntityToEntity(World world, Entity caster, Entity source, Entity target, int damage, int type) {
    if (!world.isRemote) {
        //send a packet to all clients telling them to spawn this lightning bolt!
        AMDataWriter writer = new AMDataWriter();
        //what kind of bolt are we doing?
        writer.add(PKT_RIBBON_ENT_ENT);
        writer.add(caster.getEntityId());
        writer.add(source.getEntityId());
        writer.add(target.getEntityId());
        writer.add(damage);
        writer.add(type);
        AMNetHandler.INSTANCE.sendPacketToAllClientsNear(world.provider.dimensionId, caster.posX, caster.posY, caster.posZ, 32, AMPacketIDs.PARTICLE_SPAWN_SPECIAL, writer.generate());
    }
}
Also used : AMDataWriter(am2.network.AMDataWriter)

Example 13 with AMDataWriter

use of am2.network.AMDataWriter in project ArsMagica2 by Mithion.

the class ParticleManagerServer method RibbonFromPointToPoint.

public void RibbonFromPointToPoint(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, int type) {
    if (!world.isRemote) {
        //send a packet to all clients telling them to spawn this lightning bolt!
        AMDataWriter writer = new AMDataWriter();
        //what kind of bolt are we doing?
        writer.add(PKT_RIBBON_PT_PT);
        writer.add(startX);
        writer.add(startY);
        writer.add(startZ);
        writer.add(endX);
        writer.add(endY);
        writer.add(endZ);
        writer.add(type);
        AMNetHandler.INSTANCE.sendPacketToAllClientsNear(world.provider.dimensionId, startX, startY, startZ, 32, AMPacketIDs.PARTICLE_SPAWN_SPECIAL, writer.generate());
    }
}
Also used : AMDataWriter(am2.network.AMDataWriter)

Example 14 with AMDataWriter

use of am2.network.AMDataWriter in project ArsMagica2 by Mithion.

the class AffinityHelper method onEntityLivingBase.

@SubscribeEvent
public void onEntityLivingBase(LivingUpdateEvent event) {
    EntityLivingBase ent = event.entityLiving;
    if (ent instanceof EntityEnderman) {
        if (ent.getLastAttacker() != ent.getAITarget() && ent.getAITarget() instanceof EntityPlayer) {
            AffinityData affinityData = AffinityData.For(ent.getAITarget());
            float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
            if (enderDepth == 1.0f) {
                ent.setRevengeTarget(null);
            }
        }
    }
    if (!(ent instanceof EntityPlayer))
        return;
    AffinityData affinityData = AffinityData.For(ent);
    affinityData.tickDiminishingReturns();
    float waterDepth = affinityData.getAffinityDepth(Affinity.WATER);
    float fireDepth = affinityData.getAffinityDepth(Affinity.FIRE);
    float natureDepth = affinityData.getAffinityDepth(Affinity.NATURE);
    float iceDepth = affinityData.getAffinityDepth(Affinity.ICE);
    float lifeDepth = affinityData.getAffinityDepth(Affinity.LIFE);
    float enderDepth = affinityData.getAffinityDepth(Affinity.ENDER);
    float lightningDepth = affinityData.getAffinityDepth(Affinity.LIGHTNING);
    AffinityModifiers.instance.applySpeedModifiersBasedOnDepth((EntityPlayer) ent, natureDepth, iceDepth, lightningDepth);
    AffinityModifiers.instance.applyHealthModifiers((EntityPlayer) ent, enderDepth, waterDepth, fireDepth, lightningDepth);
    applyFulmintion((EntityPlayer) ent, lightningDepth);
    if (lightningDepth >= 0.5f) {
        ent.stepHeight = 1.014f;
    } else if (ent.stepHeight == 1.014f) {
        ent.stepHeight = 0.5f;
    }
    affinityData.accumulatedLifeRegen += 0.025 * lifeDepth;
    if (affinityData.accumulatedLifeRegen > 1.0f) {
        affinityData.accumulatedLifeRegen -= 1.0f;
        ent.heal(1);
    }
    if (natureDepth == 1.0f) {
        if (ent.worldObj.canBlockSeeTheSky((int) ent.posX, (int) ent.posY, (int) ent.posZ) && ent.worldObj.isDaytime()) {
            affinityData.accumulatedHungerRegen += 0.02f;
            if (affinityData.accumulatedHungerRegen > 1.0f) {
                ((EntityPlayer) ent).getFoodStats().addStats(1, 0.025f);
                affinityData.accumulatedHungerRegen -= 1;
            }
        } else {
            ((EntityPlayer) ent).addExhaustion(0.025f);
        }
        if (ent.isCollidedHorizontally) {
            if (!ent.isSneaking()) {
                float movement = ExtendedProperties.For(ent).getIsFlipped() ? -0.25f : 0.25f;
                ent.moveEntity(0, movement, 0);
                ent.motionY = 0;
            } else {
                ent.motionY *= 0.79999999;
            }
            ent.fallDistance = 0;
        }
    }
    //Ender Affinity
    if (enderDepth >= 0.75f && affinityData.hasActivatedNightVision()) {
        if (!ent.worldObj.isRemote && (!ent.isPotionActive(Potion.nightVision.id) || ent.getActivePotionEffect(Potion.nightVision).getDuration() <= 220)) {
            ent.addPotionEffect(new PotionEffect(Potion.nightVision.id, 300, 1));
        }
    }
    if (ent.onGround)
        affinityData.setLastGroundPosition(new AMVector3(ent));
    affinityData.tickCooldown();
    if (ent.isInWater()) {
        float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
        if (earthDepth > 0.25f && ent.motionY > -0.3f) {
            ent.addVelocity(0, -0.01f * earthDepth, 0);
        }
        if (waterDepth > 0.5f) {
            if (!ent.isPotionActive(BuffList.swiftSwim.id) || ent.getActivePotionEffect(BuffList.swiftSwim).getDuration() < 10) {
                ent.addPotionEffect(new BuffEffectSwiftSwim(100, waterDepth > 0.75f ? 2 : 1));
            }
        }
        if (waterDepth > 0.4 && ent.worldObj.rand.nextInt(20) < 4)
            ent.setAir(ent.getAir() + 1);
        if (!ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 5) {
            ent.setAir(ent.getAir() + 1);
            byte[] data = new AMDataWriter().add(ent.getEntityId()).add(ent.getAir()).generate();
            AMNetHandler.INSTANCE.sendPacketToClientPlayer((EntityPlayerMP) ent, AMPacketIDs.SYNC_AIR_CHANGE, data);
        }
        boolean waterMovementFlag = false;
        if ((ent instanceof EntityPlayer && ((EntityPlayer) ent).inventory.armorInventory[1] != null && ((EntityPlayer) ent).inventory.armorInventory[1].getItem() == ItemsCommonProxy.waterGuardianOrbs)) {
            waterMovementFlag = true;
            if (!ent.worldObj.isRemote && (!ent.isPotionActive(BuffList.waterBreathing) || ent.getActivePotionEffect(BuffList.waterBreathing).getDuration() <= 200))
                ent.addPotionEffect(new BuffEffectWaterBreathing(400, 2));
        }
        if (waterDepth > 0.5f || waterMovementFlag) {
            applyReverseWaterMovement(ent);
        }
    }
    if (ent.worldObj.isRaining() && !ent.worldObj.isRemote && ent.worldObj.getBiomeGenForCoords((int) Math.floor(ent.posX), (int) Math.floor(ent.posZ)).canSpawnLightningBolt()) {
        float airDepth = affinityData.getAffinityDepth(Affinity.AIR);
        if (airDepth > 0.5f && airDepth < 0.85f && !ent.worldObj.isRemote && ent.worldObj.rand.nextInt(100) < 10) {
            if (!ent.isSneaking() && !ent.isPotionActive(BuffList.gravityWell) && !ent.isInsideOfMaterial(Material.water) && ent.isWet()) {
                double velX = ent.worldObj.rand.nextDouble() - 0.5;
                double velY = ent.worldObj.rand.nextDouble() - 0.5;
                double velZ = ent.worldObj.rand.nextDouble() - 0.5;
                ent.addVelocity(velX, velY, velZ);
                AMNetHandler.INSTANCE.sendVelocityAddPacket(ent.worldObj, ent, velX, velY, velZ);
            }
        }
    }
    if (ent.isSneaking()) {
        if (iceDepth >= 0.5f) {
            makeIceBridge((EntityPlayer) ent, iceDepth);
        }
    }
}
Also used : PotionEffect(net.minecraft.potion.PotionEffect) AffinityData(am2.playerextensions.AffinityData) AMDataWriter(am2.network.AMDataWriter) AMVector3(am2.api.math.AMVector3) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityEnderman(net.minecraft.entity.monster.EntityEnderman) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 15 with AMDataWriter

use of am2.network.AMDataWriter in project ArsMagica2 by Mithion.

the class PlayerTracker method onPlayerLogin.

@SubscribeEvent
public void onPlayerLogin(PlayerLoggedInEvent event) {
    if (hasAA(event.player)) {
        AMNetHandler.INSTANCE.requestClientAuras((EntityPlayerMP) event.player);
    }
    int[] disabledSkills = SkillTreeManager.instance.getDisabledSkillIDs();
    AMDataWriter writer = new AMDataWriter();
    writer.add(AMCore.config.getSkillTreeSecondaryTierCap()).add(disabledSkills);
    writer.add(AMCore.config.getManaCap());
    byte[] data = writer.generate();
    AMNetHandler.INSTANCE.syncLoginData((EntityPlayerMP) event.player, data);
    if (ServerTickHandler.lastWorldName != null)
        AMNetHandler.INSTANCE.syncWorldName((EntityPlayerMP) event.player, ServerTickHandler.lastWorldName);
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) AMDataWriter(am2.network.AMDataWriter) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

AMDataWriter (am2.network.AMDataWriter)38 ItemStack (net.minecraft.item.ItemStack)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)4 AMVector3 (am2.api.math.AMVector3)3 TileEntity (net.minecraft.tileentity.TileEntity)3 SkillLearnedEvent (am2.api.events.SkillLearnedEvent)2 ISpellShape (am2.api.spell.component.interfaces.ISpellShape)2 KeystoneCombination (am2.items.ItemKeystone.KeystoneCombination)2 AMDataReader (am2.network.AMDataReader)2 ExtendedProperties (am2.playerextensions.ExtendedProperties)2 KeyValuePair (am2.utility.KeyValuePair)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 SpellCastingEvent (am2.api.events.SpellCastingEvent)1 IPowerNode (am2.api.power.IPowerNode)1 ItemSpellBase (am2.api.spell.ItemSpellBase)1 ISpellComponent (am2.api.spell.component.interfaces.ISpellComponent)1 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)1 SkillPointTypes (am2.api.spell.enums.SkillPointTypes)1 SpellCastResult (am2.api.spell.enums.SpellCastResult)1