use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class PowerNodeCache method onWorldSave.
@SubscribeEvent
public void onWorldSave(WorldEvent.Save event) {
World world = event.world;
if (world.isRemote)
return;
HashMap<ChunkCoordIntPair, NBTTagCompound> saveData = PowerNodeRegistry.For(world).saveAll();
for (ChunkCoordIntPair pair : saveData.keySet()) {
SaveNBTToFile(world, pair, saveData.get(pair), AMCore.config.savePowerDataOnWorldSave());
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class PowerNodeCache method onWorldUnload.
@SubscribeEvent
public void onWorldUnload(WorldEvent.Unload event) {
World world = event.world;
saveWorldToFile(world);
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project Minechem by iopleke.
the class AugmentLight method onBlockHarvest.
@SubscribeEvent
public void onBlockHarvest(BlockEvent.HarvestDropsEvent event) {
if (event.harvester != null) {
ItemStack stack = event.harvester.getHeldItem();
if (stack != null && stack.getItem() instanceof IAugmentedItem) {
IAugmentedItem augmentedItem = (IAugmentedItem) stack.getItem();
int level = augmentedItem.getAugmentLevel(stack, this);
if (level > -1 && event.world.getBlockLightValue(event.x, event.y, event.z) < 8) {
consumeAugment(stack, level);
event.world.setBlock(event.x, event.y, event.z, BlockRegistry.blockLight, level, 3);
}
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AMPacketProcessorClient method onPacketData.
@SubscribeEvent
public void onPacketData(ClientCustomPacketEvent event) {
ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload());
byte packetID = -1;
try {
if (event.packet.getTarget() != Side.CLIENT) {
return;
}
//constant details all packets share: ID, player, and remaining data
packetID = bbis.readByte();
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
byte[] remaining = new byte[bbis.available()];
bbis.readFully(remaining);
switch(packetID) {
case AMPacketIDs.SPELL_CAST:
handleSpellCast(remaining);
break;
case AMPacketIDs.MAGIC_LEVEL_UP:
handleMagicLevelUpResponse(remaining);
break;
case AMPacketIDs.PARTICLE_SPAWN_SPECIAL:
AMCore.instance.proxy.particleManager.handleClientPacketData(Minecraft.getMinecraft().theWorld, remaining);
break;
case AMPacketIDs.PLAYER_VELOCITY_ADD:
handleVelocityAdd(remaining);
break;
case AMPacketIDs.FLASH_ARMOR_PIECE:
handleFlashArmor(remaining);
break;
case AMPacketIDs.REMOVE_BUFF_EFFECT:
handleRemoveBuffEffect(remaining);
break;
case AMPacketIDs.SYNC_EXTENDED_PROPS:
handleSyncProps(remaining);
break;
case AMPacketIDs.SYNC_BETA_PARTICLES:
handleSyncBetaParticles(remaining);
break;
case AMPacketIDs.REQUEST_BETA_PARTICLES:
handleRequestBetaParticles(remaining);
break;
case AMPacketIDs.SYNC_AIR_CHANGE:
handleSyncAir(remaining);
break;
case AMPacketIDs.SYNC_AFFINITY_DATA:
handleSyncAffinity(remaining);
break;
case AMPacketIDs.SYNC_SPELL_KNOWLEDGE:
handleSyncSpellKnowledge(remaining);
break;
case AMPacketIDs.ENTITY_ACTION_UPDATE:
handleEntityActionUpdate(remaining, player);
break;
case AMPacketIDs.PLAYER_LOGIN_DATA:
handlePlayerLoginData(remaining, player);
break;
case AMPacketIDs.NBT_DUMP:
handleNBTDump(player);
break;
case AMPacketIDs.SET_MAG_WORK_REC:
handleSetMagicicansWorkbenchRecipe(player);
break;
case AMPacketIDs.COMPENDIUM_UNLOCK:
handleCompendiumUnlock(remaining);
break;
case AMPacketIDs.SYNC_WORLD_NAME:
handleSyncWorldName(remaining);
break;
case AMPacketIDs.STAR_FALL:
handleStarFall(remaining);
break;
case AMPacketIDs.HIDDEN_COMPONENT_UNLOCK:
Minecraft.getMinecraft().guiAchievement.func_146256_a(ArcaneCompendium.componentUnlock);
break;
case AMPacketIDs.SPELL_APPLY_EFFECT:
handleSpellApplyEffect(remaining);
break;
case AMPacketIDs.HECATE_DEATH:
handleHecateDeath(remaining);
break;
case AMPacketIDs.REQUEST_PWR_PATHS:
handleRcvPowerPaths(remaining);
break;
case AMPacketIDs.CAPABILITY_CHANGE:
handleCapabilityChange(remaining);
break;
case AMPacketIDs.CRAFTING_ALTAR_DATA:
handleCraftingAltarData(remaining);
break;
case AMPacketIDs.LECTERN_DATA:
handleLecternData(remaining);
break;
case AMPacketIDs.CALEFACTOR_DATA:
handleCalefactorData(remaining);
break;
case AMPacketIDs.OBELISK_DATA:
handleObeliskData(remaining);
break;
}
} catch (Throwable t) {
LogHelper.error("Client Packet Failed to Handle!");
LogHelper.error("Packet Type: " + packetID);
t.printStackTrace();
} finally {
try {
if (bbis != null)
bbis.close();
} catch (Throwable t) {
t.printStackTrace();
}
}
}
use of cpw.mods.fml.common.eventhandler.SubscribeEvent in project ArsMagica2 by Mithion.
the class AffinityHelper method onEntityFall.
@SubscribeEvent
public void onEntityFall(LivingFallEvent event) {
EntityLivingBase ent = event.entityLiving;
if (!(ent instanceof EntityPlayer))
return;
AffinityData affinityData = AffinityData.For(ent);
float earthDepth = affinityData.getAffinityDepth(Affinity.EARTH);
if (earthDepth > 0.25f) {
event.distance += 1.25 * (earthDepth);
}
float airDepth = affinityData.getAffinityDepth(Affinity.AIR);
if (airDepth >= 0.5f) {
event.distance -= 2 * (airDepth);
if (event.distance < 0)
event.distance = 0;
}
}
Aggregations