Search in sources :

Example 21 with AMDataReader

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

the class AMPacketProcessorClient method handleCalefactorData.

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

Example 22 with AMDataReader

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

the class TileEntityInscriptionTable method HandleUpdatePacket.

public void HandleUpdatePacket(byte[] data) {
    if (this.worldObj == null)
        return;
    AMDataReader rdr = new AMDataReader(data);
    switch(rdr.ID) {
        case FULL_UPDATE:
            if (!rdr.getBoolean()) {
                Entity e = this.worldObj.getEntityByID(rdr.getInt());
                if (e instanceof EntityPlayer) {
                    EntityPlayer player = (EntityPlayer) e;
                    this.setInUse(player);
                } else {
                    this.setInUse(null);
                }
            } else {
                this.setInUse(null);
            }
            currentRecipe.clear();
            int partLength = rdr.getInt();
            for (int i = 0; i < partLength; ++i) {
                ISkillTreeEntry part = SkillManager.instance.getSkill(rdr.getInt());
                if (part instanceof ISpellPart)
                    this.currentRecipe.add((ISpellPart) part);
            }
            this.shapeGroups.clear();
            int numGroups = rdr.getInt();
            for (int i = 0; i < numGroups; ++i) {
                ArrayList<ISpellPart> group = new ArrayList<ISpellPart>();
                int[] partData = rdr.getIntArray();
                for (int n : partData) {
                    ISkillTreeEntry part = SkillManager.instance.getSkill(n);
                    if (part instanceof ISpellPart)
                        group.add((ISpellPart) part);
                }
                this.shapeGroups.add(group);
            }
            countModifiers();
            this.currentSpellName = rdr.getString();
            this.currentSpellIsReadOnly = rdr.getBoolean();
            break;
        case MAKE_SPELL:
            int entityID = rdr.getInt();
            EntityPlayer player = (EntityPlayer) worldObj.getEntityByID(entityID);
            if (player != null) {
                createSpellForPlayer(player);
            }
            break;
        case RESET_NAME:
            entityID = rdr.getInt();
            player = (EntityPlayer) worldObj.getEntityByID(entityID);
            if (player != null) {
                ((ContainerInscriptionTable) player.openContainer).resetSpellNameAndIcon();
            }
            break;
    }
}
Also used : S35PacketUpdateTileEntity(net.minecraft.network.play.server.S35PacketUpdateTileEntity) Entity(net.minecraft.entity.Entity) TileEntity(net.minecraft.tileentity.TileEntity) ContainerInscriptionTable(am2.containers.ContainerInscriptionTable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) AMDataReader(am2.network.AMDataReader)

Example 23 with AMDataReader

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

the class SkillData method handlePacketData.

public boolean handlePacketData(byte[] data) {
    try {
        AMDataReader rdr = new AMDataReader(data, false);
        byte subID = rdr.getByte();
        int entityID = rdr.getInt();
        switch(subID) {
            case SPELL_LEARNED:
                int id = rdr.getInt();
                int type = rdr.getInt();
                learn(id, type);
                if (!entity.worldObj.isRemote)
                    forceSync();
                break;
            case CLIENT_SYNC:
                int flags = rdr.getInt();
                if (rdr.getBoolean()) {
                    this.primaryTree = SkillTrees.values()[rdr.getInt()];
                }
                if ((flags & KNOWN_SHAPE_UPDATE) == KNOWN_SHAPE_UPDATE) {
                    shapesKnown.clear();
                    int numShapes = rdr.getInt();
                    for (int i = 0; i < numShapes; ++i) {
                        setShapeKnown(rdr.getInt());
                    }
                }
                if ((flags & KNOWN_COMPONENT_UPDATE) == KNOWN_COMPONENT_UPDATE) {
                    componentsKnown.clear();
                    int numComponents = rdr.getInt();
                    for (int i = 0; i < numComponents; ++i) {
                        setComponentKnown(rdr.getInt());
                    }
                }
                if ((flags & KNOWN_MODIFIER_UPDATE) == KNOWN_MODIFIER_UPDATE) {
                    modifiersKnown.clear();
                    int numModifiers = rdr.getInt();
                    for (int i = 0; i < numModifiers; ++i) {
                        setModifierKnown(rdr.getInt());
                    }
                }
                if ((flags & KNOWN_TALENTS_UPDATE) == KNOWN_TALENTS_UPDATE) {
                    talentsKnown.clear();
                    int numTalents = rdr.getInt();
                    for (int i = 0; i < numTalents; ++i) {
                        setTalentKnown(rdr.getInt());
                    }
                }
                if ((flags & NUM_SPELL_POINTS) == NUM_SPELL_POINTS) {
                    setSpellPoints(rdr.getInt(), rdr.getInt(), rdr.getInt());
                }
                break;
        }
    } catch (Throwable t) {
        t.printStackTrace();
        return false;
    }
    return true;
}
Also used : AMDataReader(am2.network.AMDataReader)

Example 24 with AMDataReader

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

the class ParticleManagerClient method handleClientPacketData.

@Override
public void handleClientPacketData(World world, byte[] data) {
    AMDataReader rdr = new AMDataReader(data);
    byte sub_id = rdr.getByte();
    int type = 1;
    String name;
    int casterID;
    int sourceID;
    int targetID;
    int damage;
    int color;
    Entity caster;
    Entity source;
    Entity target;
    double startX;
    double startY;
    double startZ;
    double endX;
    double endY;
    double endZ;
    switch(sub_id) {
        case PKT_BOLT_ENT_ENT:
            casterID = rdr.getInt();
            sourceID = rdr.getInt();
            targetID = rdr.getInt();
            damage = rdr.getInt();
            type = rdr.getInt();
            color = rdr.getInt();
            caster = world.getEntityByID(casterID);
            source = world.getEntityByID(sourceID);
            target = world.getEntityByID(targetID);
            if (caster == null || source == null || target == null) {
                return;
            }
            BoltFromEntityToEntity(world, caster, source, target, damage, type, color);
            break;
        case PKT_BOLT_PT_PT:
            startX = rdr.getDouble();
            startY = rdr.getDouble();
            startZ = rdr.getDouble();
            endX = rdr.getDouble();
            endY = rdr.getDouble();
            endZ = rdr.getDouble();
            type = rdr.getInt();
            color = rdr.getInt();
            BoltFromPointToPoint(world, startX, startY, startZ, endX, endY, endZ, type, color);
            break;
        case PKT_BEAM_ENT_ENT:
            casterID = rdr.getInt();
            sourceID = rdr.getInt();
            targetID = rdr.getInt();
            damage = rdr.getInt();
            type = rdr.getInt();
            caster = world.getEntityByID(casterID);
            source = world.getEntityByID(sourceID);
            target = world.getEntityByID(targetID);
            if (caster == null || source == null || target == null) {
                return;
            }
            BeamFromEntityToEntity(world, caster, source, target, damage, type);
            break;
        case PKT_BEAM_PT_PT:
            startX = rdr.getDouble();
            startY = rdr.getDouble();
            startZ = rdr.getDouble();
            endX = rdr.getDouble();
            endY = rdr.getDouble();
            endZ = rdr.getDouble();
            type = rdr.getInt();
            BeamFromPointToPoint(world, startX, startY, startZ, endX, endY, endZ, type);
            break;
        case PKT_RIBBON_PT_PT:
            startX = rdr.getDouble();
            startY = rdr.getDouble();
            startZ = rdr.getDouble();
            endX = rdr.getDouble();
            endY = rdr.getDouble();
            endZ = rdr.getDouble();
            type = rdr.getInt();
            RibbonFromPointToPoint(world, startX, startY, startZ, endX, endY, endZ, type);
            break;
        case PKT_RIBBON_ENT_ENT:
            casterID = rdr.getInt();
            sourceID = rdr.getInt();
            targetID = rdr.getInt();
            damage = rdr.getInt();
            type = rdr.getInt();
            caster = world.getEntityByID(casterID);
            source = world.getEntityByID(sourceID);
            target = world.getEntityByID(targetID);
            if (caster == null || source == null || target == null) {
                return;
            }
            RibbonFromEntityToEntity(world, caster, source, target, damage, type);
            break;
        case PKT_ARC_PT_PT:
            name = rdr.getString();
            startX = rdr.getDouble();
            startY = rdr.getDouble();
            startZ = rdr.getDouble();
            endX = rdr.getDouble();
            endY = rdr.getDouble();
            endZ = rdr.getDouble();
            spawn(world, name, startX, startY, startZ, endX, endY, endZ);
            break;
        case PKT_ARC_PT_ENT:
            name = rdr.getString();
            startX = rdr.getDouble();
            startY = rdr.getDouble();
            startZ = rdr.getDouble();
            targetID = rdr.getInt();
            target = world.getEntityByID(targetID);
            if (target == null) {
                return;
            }
            spawn(world, name, startX, startY, startZ, target);
            break;
        case PKT_ARC_ENT_ENT:
            name = rdr.getString();
            sourceID = rdr.getInt();
            targetID = rdr.getInt();
            source = world.getEntityByID(sourceID);
            target = world.getEntityByID(targetID);
            if (source == null || target == null) {
                return;
            }
            spawn(world, name, source, target);
            break;
    }
}
Also used : Entity(net.minecraft.entity.Entity) AMDataReader(am2.network.AMDataReader)

Example 25 with AMDataReader

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

the class ExtendedProperties method readAuraData.

public void readAuraData(byte[] data) {
    AMDataReader rdr = new AMDataReader(data, false);
    this.AuraIndex = rdr.getInt();
    this.AuraBehaviour = rdr.getInt();
    this.AuraScale = rdr.getFloat();
    this.AuraAlpha = rdr.getFloat();
    this.AuraColorRandomize = rdr.getBoolean();
    this.AuraColorDefault = rdr.getBoolean();
    this.AuraColor = rdr.getInt();
    this.AuraDelay = rdr.getInt();
    this.AuraQuantity = rdr.getInt();
    this.AuraSpeed = rdr.getFloat();
}
Also used : AMDataReader(am2.network.AMDataReader)

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