Search in sources :

Example 6 with NetHandlerPlayServer

use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.

the class PacketEditInventoryItemHandler method processServer.

@Override
public void processServer(P message, MessageContext ctx, WorldServer server) {
    NetHandlerPlayServer playServer = ctx.getServerHandler();
    EntityPlayerMP player = playServer.player;
    affectItem(player, player.inventory.getStackInSlot(message.getInventorySlot()), message);
    player.openContainer.detectAndSendChanges();
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Example 7 with NetHandlerPlayServer

use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.

the class PacketInspectEntityHandler method processServer.

@Override
public void processServer(PacketInspectEntity message, MessageContext ctx, WorldServer world) {
    NetHandlerPlayServer playServer = ctx.getServerHandler();
    EntityPlayerMP player = playServer.player;
    if (RecurrentComplex.checkPerms(player))
        return;
    Entity entity = world.getEntityFromUuid(message.getUuid());
    if (entity != null)
        entity.readFromNBT(message.getData());
}
Also used : Entity(net.minecraft.entity.Entity) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Example 8 with NetHandlerPlayServer

use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.

the class PacketSaveInvGenComponentHandler method processServer.

@Override
public void processServer(PacketSaveInvGenComponent message, MessageContext ctx, WorldServer server) {
    NetHandlerPlayServer playServer = ctx.getServerHandler();
    EntityPlayerMP player = playServer.player;
    if (RecurrentComplex.checkPerms(player))
        return;
    SaveDirectoryData.Result saveDirectoryDataResult = message.getSaveDirectoryDataResult();
    String id = message.getKey();
    ResourceDirectory saveDir = saveDirectoryDataResult.directory;
    ResourceDirectory delDir = saveDir.opposite();
    GenericItemCollectionRegistry.INSTANCE.register(id, "", message.getInventoryGenerator(), saveDir.isActive(), saveDir.getLevel());
    if (RCCommands.informSaveResult((message.getInventoryGenerator() != null && id != null) && RecurrentComplex.saver.trySave(saveDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, saveDir, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id)) {
        if (saveDirectoryDataResult.deleteOther)
            RCCommands.informDeleteResult(RecurrentComplex.saver.tryDeleteWithID(delDir.toPath(), RCFileSaver.INVENTORY_GENERATION_COMPONENT, id), player, RCFileSaver.INVENTORY_GENERATION_COMPONENT, id, delDir);
        ItemStack heldItem = playServer.player.getHeldItem(EnumHand.MAIN_HAND);
        if (heldItem != null && heldItem.getItem() instanceof ItemInventoryGenComponentTag)
            ItemInventoryGenComponentTag.setComponentKey(heldItem, id);
        player.openContainer.detectAndSendChanges();
    }
}
Also used : ResourceDirectory(ivorius.reccomplex.files.loading.ResourceDirectory) SaveDirectoryData(ivorius.reccomplex.utils.SaveDirectoryData) ItemInventoryGenComponentTag(ivorius.reccomplex.item.ItemInventoryGenComponentTag) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Example 9 with NetHandlerPlayServer

use of net.minecraft.network.NetHandlerPlayServer in project RecurrentComplex by Ivorforce.

the class PacketInspectBlockHandler method processServer.

@Override
public void processServer(PacketInspectBlock message, MessageContext ctx, WorldServer world) {
    NetHandlerPlayServer playServer = ctx.getServerHandler();
    EntityPlayerMP player = playServer.player;
    if (RecurrentComplex.checkPerms(player))
        return;
    setBlock(world, message.getPos(), message.getState(), message.getTileEntityData());
}
Also used : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer)

Example 10 with NetHandlerPlayServer

use of net.minecraft.network.NetHandlerPlayServer in project ArsMagica2 by Mithion.

the class AMPacketProcessorServer method onServerPacketData.

@SubscribeEvent
public void onServerPacketData(ServerCustomPacketEvent event) {
    ByteBufInputStream bbis = new ByteBufInputStream(event.packet.payload());
    byte packetID = -1;
    try {
        if (event.packet.getTarget() != Side.SERVER) {
            return;
        }
        //constant details all packets share:  ID, player, and remaining data
        packetID = bbis.readByte();
        NetHandlerPlayServer srv = (NetHandlerPlayServer) event.packet.handler();
        EntityPlayerMP player = srv.playerEntity;
        byte[] remaining = new byte[bbis.available()];
        bbis.readFully(remaining);
        switch(packetID) {
            case AMPacketIDs.SPELL_SHAPE_GROUP_CHANGE:
                handleCastingModeChange(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.MAGIC_LEVEL_UP:
                handleMagicLevelUp(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.SYNC_BETA_PARTICLES:
                handleSyncBetaParticles(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.POSSIBLE_CLIENT_EXPROP_DESYNC:
                handlePossibleClientExpropDesync(remaining);
                break;
            case AMPacketIDs.REQUEST_BETA_PARTICLES:
                handleRequestBetaParticles(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.SPELL_CUSTOMIZE:
                handleSpellCustomize(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.SPELLBOOK_CHANGE_ACTIVE_SLOT:
                handleSpellBookChangeActiveSlot(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.SYNC_SPELL_KNOWLEDGE:
                handleSyncSpellKnowledge(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.DECO_BLOCK_UPDATE:
                handleDecoBlockUpdate(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.INSCRIPTION_TABLE_UPDATE:
                handleInscriptionTableUpdate(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.TK_DISTANCE_SYNC:
                ExtendedProperties.For((EntityPlayerMP) player).TK_Distance = new AMDataReader(remaining).getFloat();
                break;
            case AMPacketIDs.SAVE_KEYSTONE_COMBO:
                handleSaveKeystoneCombo(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.SET_KEYSTONE_COMBO:
                handleSetKeystoneCombo(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.SET_MAG_WORK_REC:
                handleSetMagiciansWorkbenchRecipe(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.RUNE_BAG_GUI_OPEN:
                handleRuneBagGUIOpen(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.M_BENCH_LOCK_RECIPE:
                handleMBenchLockRecipe(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.IMBUE_ARMOR:
                handleImbueArmor(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.REQUEST_PWR_PATHS:
                handlePowerPathSync(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.SYNC_EXTENDED_PROPS:
                handleExpropOperation(remaining, (EntityPlayerMP) player);
                break;
            case AMPacketIDs.AFFINITY_ACTIVATE:
                handleAffinityActivate(remaining, player);
                break;
        }
    } catch (Throwable t) {
        LogHelper.error("Server 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 : EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ByteBufInputStream(io.netty.buffer.ByteBufInputStream) NetHandlerPlayServer(net.minecraft.network.NetHandlerPlayServer) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Aggregations

NetHandlerPlayServer (net.minecraft.network.NetHandlerPlayServer)11 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)7 GameProfile (com.mojang.authlib.GameProfile)2 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)2 SaveDirectoryData (ivorius.reccomplex.utils.SaveDirectoryData)2 ItemStack (net.minecraft.item.ItemStack)2 NetworkManager (net.minecraft.network.NetworkManager)2 WorldServer (net.minecraft.world.WorldServer)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 FakePlayerItemInWorldManager (pneumaticCraft.common.ai.FakePlayerItemInWorldManager)2 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ByteBufInputStream (io.netty.buffer.ByteBufInputStream)1 RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)1 ItemInventoryGenComponentTag (ivorius.reccomplex.item.ItemInventoryGenComponentTag)1 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)1 RfToolsDimensionManager (mcjty.rftoolsdim.dimensions.RfToolsDimensionManager)1 DimensionSyncPacket (mcjty.rftoolsdim.network.DimensionSyncPacket)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 InventoryPlayer (net.minecraft.entity.player.InventoryPlayer)1