Search in sources :

Example 16 with AMDataWriter

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

the class TileEntityInscriptionTable method createSpellForPlayer.

public void createSpellForPlayer(EntityPlayer player) {
    if (worldObj.isRemote) {
        AMDataWriter writer = new AMDataWriter();
        writer.add(xCoord);
        writer.add(yCoord);
        writer.add(zCoord);
        writer.add(MAKE_SPELL);
        writer.add(player.getEntityId());
        AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.INSCRIPTION_TABLE_UPDATE, writer.generate());
    } else {
        ArrayList<ArrayList<KeyValuePair<ISpellPart, byte[]>>> shapeGroupSetup = new ArrayList<ArrayList<KeyValuePair<ISpellPart, byte[]>>>();
        ArrayList<KeyValuePair<ISpellPart, byte[]>> curRecipeSetup = new ArrayList<KeyValuePair<ISpellPart, byte[]>>();
        for (ArrayList<ISpellPart> arr : shapeGroups) {
            shapeGroupSetup.add(new ArrayList<KeyValuePair<ISpellPart, byte[]>>());
            for (ISpellPart part : arr) {
                shapeGroupSetup.get(shapeGroupSetup.size() - 1).add(new KeyValuePair<ISpellPart, byte[]>(part, new byte[0]));
            }
        }
        for (ISpellPart part : currentRecipe) {
            curRecipeSetup.add(new KeyValuePair<ISpellPart, byte[]>(part, new byte[0]));
        }
        ItemStack stack = SpellUtils.instance.createSpellStack(shapeGroupSetup, curRecipeSetup);
        stack.stackTagCompound.setString("suggestedName", currentSpellName);
        player.inventory.addItemStackToInventory(stack);
    }
}
Also used : KeyValuePair(am2.utility.KeyValuePair) ItemStack(net.minecraft.item.ItemStack) AMDataWriter(am2.network.AMDataWriter)

Example 17 with AMDataWriter

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

the class TileEntityInscriptionTable method GetUpdatePacketForServer.

private byte[] GetUpdatePacketForServer() {
    AMDataWriter writer = new AMDataWriter();
    writer.add(FULL_UPDATE);
    writer.add(this.currentPlayerUsing == null);
    if (this.currentPlayerUsing != null)
        writer.add(this.currentPlayerUsing.getEntityId());
    writer.add(this.currentRecipe.size());
    for (int i = 0; i < this.currentRecipe.size(); ++i) {
        ISpellPart part = this.currentRecipe.get(i);
        int id = part.getID();
        if (part instanceof ISpellComponent)
            id += SkillManager.COMPONENT_OFFSET;
        else if (part instanceof ISpellModifier)
            id += SkillManager.MODIFIER_OFFSET;
        writer.add(id);
    }
    writer.add(this.shapeGroups.size());
    for (ArrayList<ISpellPart> shapeGroup : this.shapeGroups) {
        int[] groupData = new int[shapeGroup.size()];
        for (int i = 0; i < shapeGroup.size(); ++i) {
            groupData[i] = SkillManager.instance.getShiftedPartID(shapeGroup.get(i));
        }
        writer.add(groupData);
    }
    writer.add(currentSpellName);
    writer.add(currentSpellIsReadOnly);
    return writer.generate();
}
Also used : AMDataWriter(am2.network.AMDataWriter)

Example 18 with AMDataWriter

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

the class TileEntityInscriptionTable method sendDataToServer.

private void sendDataToServer() {
    AMDataWriter writer = new AMDataWriter();
    writer.add(xCoord);
    writer.add(yCoord);
    writer.add(zCoord);
    writer.add(GetUpdatePacketForServer());
    AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.INSCRIPTION_TABLE_UPDATE, writer.generate());
}
Also used : AMDataWriter(am2.network.AMDataWriter)

Example 19 with AMDataWriter

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

the class ContainerSpellCustomization method sendPacketToServer.

public boolean sendPacketToServer() {
    if (!name.equals("") && iconIndex > -1) {
        AMDataWriter writer = new AMDataWriter();
        writer.add(inventoryPlayer.player.getEntityId());
        writer.add(iconIndex);
        writer.add(name);
        AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.SPELL_CUSTOMIZE, writer.generate());
        return true;
    }
    return false;
}
Also used : AMDataWriter(am2.network.AMDataWriter)

Example 20 with AMDataWriter

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

the class TileEntityParticleEmitter method syncWithServer.

public void syncWithServer() {
    if (this.worldObj.isRemote) {
        AMDataWriter writer = new AMDataWriter();
        writer.add(this.xCoord);
        writer.add(this.yCoord);
        writer.add(this.zCoord);
        NBTTagCompound compound = new NBTTagCompound();
        this.writeToNBT(compound);
        writer.add(compound);
        byte[] data = writer.generate();
        AMNetHandler.INSTANCE.sendPacketToServer(AMPacketIDs.DECO_BLOCK_UPDATE, data);
    }
}
Also used : NBTTagCompound(net.minecraft.nbt.NBTTagCompound) AMDataWriter(am2.network.AMDataWriter)

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