Search in sources :

Example 41 with SubscribeEvent

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());
    }
}
Also used : ChunkCoordIntPair(net.minecraft.world.ChunkCoordIntPair) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) World(net.minecraft.world.World) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 42 with SubscribeEvent

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);
}
Also used : World(net.minecraft.world.World) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 43 with SubscribeEvent

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);
            }
        }
    }
}
Also used : IAugmentedItem(minechem.item.augment.IAugmentedItem) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 44 with SubscribeEvent

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();
        }
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) ByteBufInputStream(io.netty.buffer.ByteBufInputStream) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 45 with SubscribeEvent

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;
    }
}
Also used : EntityLivingBase(net.minecraft.entity.EntityLivingBase) AffinityData(am2.playerextensions.AffinityData) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)109 EntityPlayer (net.minecraft.entity.player.EntityPlayer)45 ItemStack (net.minecraft.item.ItemStack)45 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)14 EntityLivingBase (net.minecraft.entity.EntityLivingBase)11 World (net.minecraft.world.World)11 Minecraft (net.minecraft.client.Minecraft)10 ChunkPosition (net.minecraft.world.ChunkPosition)9 EntityItem (net.minecraft.entity.item.EntityItem)8 ChatComponentText (net.minecraft.util.ChatComponentText)8 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)6 AffinityData (am2.playerextensions.AffinityData)5 SideOnly (cpw.mods.fml.relauncher.SideOnly)5 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 Block (net.minecraft.block.Block)5 EntityEnderman (net.minecraft.entity.monster.EntityEnderman)5 ChunkCoordIntPair (net.minecraft.world.ChunkCoordIntPair)5 ExtendedProperties (am2.playerextensions.ExtendedProperties)4