Search in sources :

Example 6 with AMDataReader

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

the class AMPacketProcessorClient method handleStarFall.

private void handleStarFall(byte[] data) {
    AMDataReader rdr = new AMDataReader(data, false);
    double x = rdr.getDouble();
    double y = rdr.getDouble();
    double z = rdr.getDouble();
    ItemStack spellStack = null;
    if (rdr.getBoolean())
        spellStack = rdr.getItemStack();
    int color = -1;
    if (spellStack != null) {
        if (SpellUtils.instance.modifierIsPresent(SpellModifiers.COLOR, spellStack, 0)) {
            ISpellModifier[] mods = SpellUtils.instance.getModifiersForStage(spellStack, 0);
            int ordinalCount = 0;
            for (ISpellModifier mod : mods) {
                if (mod instanceof Colour) {
                    byte[] meta = SpellUtils.instance.getModifierMetadataFromStack(spellStack, mod, 0, ordinalCount++);
                    color = (int) mod.getModifier(SpellModifiers.COLOR, null, null, null, meta);
                }
            }
        }
    }
    for (int i = 0; i < 360; i += AMCore.config.FullGFX() ? 5 : AMCore.config.LowGFX() ? 10 : 20) {
        AMParticle effect = (AMParticle) AMCore.instance.proxy.particleManager.spawn(Minecraft.getMinecraft().theWorld, "sparkle2", x, y + 1.5, z);
        if (effect != null) {
            effect.setIgnoreMaxAge(true);
            effect.AddParticleController(new ParticleMoveOnHeading(effect, i, 0, 0.7f, 1, false));
            float clrMod = Minecraft.getMinecraft().theWorld.rand.nextFloat();
            int finalColor = -1;
            if (color == -1)
                finalColor = MathUtilities.colorFloatsToInt(0.24f * clrMod, 0.58f * clrMod, 0.71f * clrMod);
            else {
                float[] colors = MathUtilities.colorIntToFloats(color);
                for (int c = 0; c < colors.length; ++c) colors[c] = colors[c] * clrMod;
                finalColor = MathUtilities.colorFloatsToInt(colors[0], colors[1], colors[2]);
            }
            effect.setParticleScale(1.2f);
            effect.noClip = false;
            effect.setRGBColorI(finalColor);
            effect.AddParticleController(new ParticleFadeOut(effect, 1, false).setFadeSpeed(0.05f).setKillParticleOnFinish(true));
            effect.AddParticleController(new ParticleLeaveParticleTrail(effect, "sparkle2", false, 15, 1, false).addControllerToParticleList(new ParticleChangeSize(effect, 1.2f, 0.01f, 15, 1, false)).setParticleRGB_I(finalColor).setChildAffectedByGravity().addRandomOffset(0.2f, 0.2f, 0.2f));
        }
    }
    Minecraft.getMinecraft().theWorld.playSound(x, y, z, "arsmagica2:spell.special.starfall", 2.0f, 1.0f, false);
}
Also used : ISpellModifier(am2.api.spell.component.interfaces.ISpellModifier) Colour(am2.spell.modifiers.Colour) ItemStack(net.minecraft.item.ItemStack)

Example 7 with AMDataReader

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

the class AMPacketProcessorClient method handleCraftingAltarData.

private void handleCraftingAltarData(byte[] data) {
    AMDataReader rdr = new AMDataReader(data, false);
    TileEntity te = Minecraft.getMinecraft().theWorld.getTileEntity(rdr.getInt(), rdr.getInt(), rdr.getInt());
    if (te == null || !(te instanceof TileEntityCraftingAltar))
        return;
    ((TileEntityCraftingAltar) te).HandleUpdatePacket(rdr.getRemainingBytes());
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCraftingAltar(am2.blocks.tileentities.TileEntityCraftingAltar)

Example 8 with AMDataReader

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

the class AMPacketProcessorServer method handlePowerPathSync.

private void handlePowerPathSync(byte[] data, EntityPlayerMP player) {
    AMDataReader rdr = new AMDataReader(data, false);
    byte nom = rdr.getByte();
    if (nom == 1) {
        AMVector3 loc = new AMVector3(rdr.getFloat(), rdr.getFloat(), rdr.getFloat());
        TileEntity te = player.worldObj.getTileEntity((int) loc.x, (int) loc.y, (int) loc.z);
        if (te != null && te instanceof IPowerNode) {
            AMNetHandler.INSTANCE.sendPowerResponseToClient(PowerNodeRegistry.For(player.worldObj).getDataCompoundForNode((IPowerNode) te), player, te);
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AMVector3(am2.api.math.AMVector3) IPowerNode(am2.api.power.IPowerNode)

Example 9 with AMDataReader

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

the class AMPacketProcessorServer method handlePossibleClientExpropDesync.

private void handlePossibleClientExpropDesync(byte[] data) {
    AMDataReader rdr = new AMDataReader(data, false);
    int entityID = rdr.getInt();
    EntityLivingBase e = getEntityByID(entityID);
    if (e != null && e instanceof EntityPlayer) {
        ExtendedProperties props = ExtendedProperties.For(e);
        if (!props.detectPossibleDesync()) {
            props.setFullSync();
            props.forceSync();
        }
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ExtendedProperties(am2.playerextensions.ExtendedProperties)

Example 10 with AMDataReader

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

the class AMPacketProcessorServer method handleDecoBlockUpdate.

private void handleDecoBlockUpdate(byte[] data, EntityPlayerMP player) {
    World world = player.worldObj;
    AMDataReader rdr = new AMDataReader(data, false);
    TileEntity te = world.getTileEntity(rdr.getInt(), rdr.getInt(), rdr.getInt());
    if (te == null || !(te instanceof TileEntityParticleEmitter))
        return;
    ((TileEntityParticleEmitter) te).readFromNBT(rdr.getNBTTagCompound());
    world.markBlockForUpdate(te.xCoord, te.yCoord, te.zCoord);
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityParticleEmitter(am2.blocks.tileentities.TileEntityParticleEmitter) World(net.minecraft.world.World)

Aggregations

TileEntity (net.minecraft.tileentity.TileEntity)14 AMDataReader (am2.network.AMDataReader)10 Entity (net.minecraft.entity.Entity)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 AMVector3 (am2.api.math.AMVector3)2 IPowerNode (am2.api.power.IPowerNode)2 AMDataWriter (am2.network.AMDataWriter)2 ItemStack (net.minecraft.item.ItemStack)2 World (net.minecraft.world.World)2 ISpellModifier (am2.api.spell.component.interfaces.ISpellModifier)1 TileEntityArmorImbuer (am2.blocks.tileentities.TileEntityArmorImbuer)1 TileEntityCalefactor (am2.blocks.tileentities.TileEntityCalefactor)1 TileEntityCraftingAltar (am2.blocks.tileentities.TileEntityCraftingAltar)1 TileEntityInscriptionTable (am2.blocks.tileentities.TileEntityInscriptionTable)1 TileEntityLectern (am2.blocks.tileentities.TileEntityLectern)1 TileEntityMagiciansWorkbench (am2.blocks.tileentities.TileEntityMagiciansWorkbench)1 TileEntityObelisk (am2.blocks.tileentities.TileEntityObelisk)1 TileEntityParticleEmitter (am2.blocks.tileentities.TileEntityParticleEmitter)1 IArsMagicaBoss (am2.bosses.IArsMagicaBoss)1