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