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