Java 类net.minecraftforge.fml.common.network.simpleimpl.MessageContext 实例源码

项目:LagGoggles    文件:TeleportRequestHandler.java   
@Override
public IMessage onMessage(TeleportRequest message, MessageContext ctx) {
    EntityPlayerMP player = ctx.getServerHandler().player;
    if(Perms.isOP(player) == false){
        Main.LOGGER.info(player.getName() + " tried to teleport, but was denied to do so!");
        return null;
    }
    new RunInServerThread(new Runnable() {
        @Override
        public void run() {
            Entity e = FMLCommonHandler.instance().getMinecraftServerInstance().getEntityFromUuid(message.uuid);
            if(e == null){
                player.sendMessage(new TextComponentString(TextFormatting.RED + "Woops! This tile entity no longer exists!"));
                return;
            }
            Teleport.teleportPlayer(player, e.dimension, e.posX, e.posY, e.posZ);
        }
    });
    return null;
}
项目:Loot-Slash-Conquer    文件:PacketUpdateChunkLevel.java   
@Override
public IMessage onMessage(final PacketUpdateChunkLevel message, final MessageContext ctx) 
{           
    IThreadListener mainThread = Minecraft.getMinecraft();
    mainThread.addScheduledTask(new Runnable()
    {
        @Override
        public void run() 
        {
            World world = Minecraft.getMinecraft().world;
            ChunkPos chunkPos = new ChunkPos(message.chunkX, message.chunkZ);

            IChunkLevelHolder chunkLevelHolder = CapabilityChunkLevel.getChunkLevelHolder(world);

            if (chunkLevelHolder.getChunkLevel(chunkPos) != null) return;

            IChunkLevel chunkLevel = new ChunkLevel(world, chunkPos, message.level);
            chunkLevelHolder.setChunkLevel(chunkPos, chunkLevel);
        }
    });

    return null;
}
项目:Proyecto-DASI    文件:SimpleCraftCommandsImplementation.java   
@Override
public IMessage onMessage(CraftMessage message, MessageContext ctx)
{
    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    // Try crafting recipes first:
    List<IRecipe> matching_recipes = CraftingHelper.getRecipesForRequestedOutput(message.parameters);
    for (IRecipe recipe : matching_recipes)
    {
        if (CraftingHelper.attemptCrafting(player, recipe))
            return null;
    }
    // Now try furnace recipes:
    ItemStack input = CraftingHelper.getSmeltingRecipeForRequestedOutput(message.parameters);
    if (input != null)
    {
        if (CraftingHelper.attemptSmelting(player, input))
            return null;
    }
    return null;
}
项目:genera    文件:MessageGlassJarUpdateStats.java   
@Override
public IMessage onMessage(MessageGlassJarUpdateStats message, MessageContext ctx) {
    ItemStack stack = message.stack;
    BlockPos pos = message.pos;
    WorldClient world = Minecraft.getMinecraft().world;
    if (world.isBlockLoaded(pos) &&
            world.getBlockState(pos).getBlock().hasTileEntity(world.getBlockState(pos))) {
        TileEntity te = world.getTileEntity(pos);
        if (te instanceof TileFaerieHome) {
            IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
            if (handler != null) {
                handler.insertItem(0, stack, false);
            }
        }
    }
    return null;
}
项目:SimpleTubes    文件:PacketDisplacerGuiColor.java   
@Override
public IMessage onMessage(final PacketDisplacerGuiColor msg, MessageContext ctx) {

    ctx.getServerHandler().player.getServerWorld().addScheduledTask(new Runnable() {
        @Override
        public void run() {

            if (msg.col != null) {
                for (int i = 0; i < msg.col.length; i++)
                    ((TileDisplacer) msg.tile).setFilterColor(i, msg.col[i]);
            }
        }
    });

    return null;
}
项目:Mods    文件:TF2DisguiseHandler.java   
@Override
public IMessage onMessage(final DisguiseMessage message, MessageContext ctx) {
    final EntityPlayerMP player = ctx.getServerHandler().player;
    ((WorldServer) player.world).addScheduledTask(new Runnable() {

        @Override
        public void run() {
            ItemStack stack;
            if (((stack = player.getHeldItemMainhand()) != null && stack.getItem() instanceof ItemDisguiseKit)
                    || ((stack = player.getHeldItemOffhand()) != null
                            && stack.getItem() instanceof ItemDisguiseKit)) {
                ItemDisguiseKit.startDisguise(player, player.world, message.value);
                if (!player.capabilities.isCreativeMode)
                    stack.damageItem(1, player);
            }
        }

    });
    return null;
}
项目:Bewitchment    文件:BrewMessage.java   
@Override
public IMessage onMessage(BrewMessage message, MessageContext ctx) {
    Minecraft.getMinecraft().addScheduledTask(() -> {
        World world = Minecraft.getMinecraft().player.world;

        EntityLivingBase entity = world.getPlayerEntityByUUID(message.target);
        if (entity == null) {
            entity = NBTHelper.getEntityByUUID(EntityLivingBase.class, message.target, world).orElse(null);
        }

        if (entity != null) {
            Optional<IBrewStorage> optional = BrewStorageHandler.getBrewStorage(entity);
            if (optional.isPresent()) {
                IBrewStorage storage = optional.get();
                storage.setBrewMap(message.effects);
            }
        }
    });
    return null;
}
项目:CraftingParadiseMod    文件:HandlerBiomeChange.java   
private void processMessage(MessageBiomeChange message, MessageContext ctx, WorldClient world)
{
    Biome targetBiome = Biome.getBiomeForId(message.biomeID);
    if(targetBiome == null)
        return;

    byte[] currentArray;
    for(byte nX = -5; nX <= 5; nX++)
    {
        for(byte nZ = -5; nZ <= 5; nZ++)
        {
            Chunk c = world.getChunkFromBlockCoords(new BlockPos(message.changeCenter.getX() + nX*16, 0, message.changeCenter.getZ() + nZ*16));
            currentArray = c.getBiomeArray();
            for(int n = 0; n < currentArray.length; n++)
            {
                currentArray[n] = (byte) Biome.getIdForBiome(targetBiome);
            }
            c.setBiomeArray(currentArray);
            c.setModified(true);
        }
    }
}
项目:Game-Stages    文件:PacketStageAll.java   
@Override
@SideOnly(Side.CLIENT)
public IMessage handleMessage (MessageContext context) {

    Minecraft.getMinecraft().addScheduledTask( () -> {

        final EntityPlayer player = PlayerUtils.getClientPlayer();
        final IStageData info = PlayerDataHandler.getStageData(player);

        // Remove all stages
        info.clear();

        // Re-add all stages
        for (final String stageName : this.stages) {
            info.unlockStage(stageName);
        }

        MinecraftForge.EVENT_BUS.post(new StageDataEvent.SyncRecieved(player, info));
    });

    return null;
}
项目:SimpleTubes    文件:PacketItemAdd.java   
@Override
public IMessage onMessage(final PacketItemAdd msg, MessageContext ctx) {

    Minecraft.getMinecraft().addScheduledTask(new Runnable() {
        @Override
        public void run() {

            if (msg.tile != null) {
                if (msg.tile instanceof TileTube) {
                    TileTube tube = (TileTube) msg.tile;
                    TubeItem item = TubeItem.createFromPacket(tube, msg.id, msg.stack, msg.progress, msg.direction, msg.color);
                    tube.handleItemClientSide(TileTube.ITEM_ADD, item);
                }
            }
        }
    });

    return null;
}
项目:ArcaneMagic    文件:PacketNotebookToastOrFail.java   
private void handle(PacketNotebookToastOrFail message, MessageContext ctx)
{
    INotebookInfo cap = Minecraft.getMinecraft().player.getCapability(INotebookInfo.CAP, null);

    if (cap != null)
    {
        if (message.cat != null && !cap.isUnlocked(message.cat.getRequiredTag()))
        {
            cap.setUnlocked(message.cat.getRequiredTag());
            ArcaneMagic.proxy.addCategoryUnlockToast(message.cat, false);
        } else if (message.showIfFail)
        {
            Minecraft.getMinecraft().ingameGUI.setOverlayMessage(
                    TextFormatting.RED + I18n.format("arcanemagic.message.cantlearn"), false);
        }
    }
}
项目:PurificatiMagicae    文件:SPacketUnlock.java   
@Override
public IMessage onMessage(SPacketUnlock message, MessageContext ctx)
{
    ctx.getServerHandler().player.getServerWorld().addScheduledTask(() ->
    {
        boolean result = false;
        TileEntity te = ctx.getServerHandler().player.world.getTileEntity(message.pos);
        if(te != null && te instanceof TileCodeStorage)
        {
            TileCodeStorage storage = (TileCodeStorage) te;
            result = storage.tryUnlock(message.code);
        }
        NetworkManager.sendTo(new CPacketUnlockResponse(result), ctx.getServerHandler().player);
    });
    return null;
}
项目:SimpleTubes    文件:PacketTubeSync.java   
@Override
public IMessage onMessage(final PacketTubeSync msg, MessageContext ctx) {

    Minecraft.getMinecraft().addScheduledTask(new Runnable() {
        @Override
        public void run() {

            if (msg.tile != null && msg.tile instanceof TileTube) {
                ((TileTube) msg.tile).setTubeColor(msg.color);
                ((TileTube) msg.tile).markDirty();

                BlockPos pos = msg.tile.getPos();
                IBlockState state = msg.tile.getWorld().getBlockState(pos);
                msg.tile.getWorld().markAndNotifyBlock(pos, null, state, state, 2);
            }
        }
    });

    return null;
}
项目:OpenFlexiTrack    文件:TileEntitySyncPacket.java   
@Override
public IMessage onMessage(final TileEntitySyncPacket message, final MessageContext ctx){
    FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(new Runnable(){
        @Override
        public void run(){
            TileEntity tile;
            if(ctx.side.isServer()){
                tile = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(new BlockPos(message.x, message.y, message.z));
            }else{
                tile = Minecraft.getMinecraft().theWorld.getTileEntity(new BlockPos(message.x, message.y, message.z));
            }
            if(tile != null){
                tile.readFromNBT(message.tag);
            }
            if(ctx.side.isServer()){
                OFT.OFTNet.sendToAll(message);
            }
        }
    });
    return null;
}
项目:Randores2    文件:RandoresDataNeededQueryHandler.java   
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(RandoresDataNeededQuery message, MessageContext ctx) {
    Minecraft.getMinecraft().addScheduledTask(() -> {
        Randores.debug("Received data needed query from server: " + message.getId());
        World world = Minecraft.getMinecraft().world;
        RandoresWorldData data = RandoresWorldData.getSimply(world);
        if(!data.isLoaded() || !data.getId().equals(message.getId())) {
            RandoresNetworking.INSTANCE.sendToServer(new RandoresDataRequest().setId(message.getId()));
            Randores.debug("Sent request for data; an update is required");
        } else {
            Randores.debug("Update not required.");
        }
    });
    return null;
}
项目:BetterBeginningsReborn    文件:PacketCampfireState.java   
@Override
protected void processMessage(PacketCampfireState message, MessageContext ctx) 
{
    EntityPlayer player = ModMain.proxy.getPlayerFromMessageContext(ctx);

    TileEntityCampfire campfire = (TileEntityCampfire)player.world.getTileEntity(message.pos);

    if (campfire != null)
    {
        campfire.campfireState = message.state;
    }
}
项目:DebugServerInfo    文件:Data.java   
@Override
        public IMessage onMessage(Data message, MessageContext ctx)
        {
//            DebugServerInfo.getLogger().info("Got data packet");
            DebugServerInfo.getProxy().handleData(message.meanTickTime, message.jMap, message.free, message.total, message.max);
            return null;
        }
项目:Defier    文件:PacketEnergyProviderSend.java   
private void handle(PacketEnergyProviderSend message, MessageContext ctx) {
    EnergyProviderTileEntity te = (EnergyProviderTileEntity) Minecraft.getMinecraft().world.getTileEntity(message.pos);
    if(te != null){
        te.laser_timer = 20;
        te.laser_target = message.dest;
        Minecraft.getMinecraft().world.playSound(message.pos, SoundEvents.BLOCK_NOTE_XYLOPHONE, SoundCategory.BLOCKS, 0.5f, 1f, false);
    }
}
项目:MineCamera    文件:MessagePlayerViewRender.java   
@Override
public IMessage onMessage(MessagePlayerViewRender message, MessageContext ctx) {
    if (ctx.side == Side.SERVER) {
        if(ctx.getServerHandler().playerEntity!=null){
            ctx.getServerHandler().playerEntity.getEntityData().removeTag("renderViewCamera");
        }
    }
    return null;
}
项目:BetterBeginningsReborn    文件:PacketHandlerBase.java   
@Override
public R onMessage(final M message, final MessageContext ctx) 
{
    if(ctx.side == Side.SERVER)
    {
        FMLServerHandler.instance().getServer().addScheduledTask(new Runnable() 
        {
            @Override
            public void run() 
            {
                processMessage(message, ctx);
            }

        });
    }
    else if(ctx.side == Side.CLIENT)
    {
        Minecraft.getMinecraft().addScheduledTask(new Runnable() 
        {
            @Override
            public void run() 
            {
                processMessage(message, ctx);
            }

        });
    }
    return null;
}
项目:MineCamera    文件:MessageSpawnParticle.java   
@Override
public IMessage onMessage(MessageSpawnParticle message, MessageContext ctx) {
    System.out.println(ctx.side.toString());
    if (ctx.side == Side.CLIENT) {
        SpawnParticleAsyncThread thread = new SpawnParticleAsyncThread(message.delay, message.typeid,
                message.PosX, message.PosY, message.PosZ, message.SpeedX, message.SpeedY, message.SpeedZ);
        thread.start();
    }
    return null;
}
项目:VoidApi    文件:VoidNetHandler.java   
@Override
public IMessage onMessage(Packet message, MessageContext ctx) 
{
    if (VoidNetwork.handlers.containsKey(message.id))
    {
        VoidNetwork.handlers.get(message.id).handleData(message.data);
    }
    else
    {
        VCLoggers.loggerErrors.log(LogLevel.Error, "Packet with ID %d arrived at %s but it has no handler registered and thus can't be processed!", message.id, MC.getSide().name());
    }

    return null;
}
项目:MineCamera    文件:MessagePictureBookInput.java   
@Override
public IMessage onMessage(MessagePictureBookInput message, MessageContext ctx) {
    if (ctx.side == Side.SERVER) {
        EntityPlayerMP player = ctx.getServerHandler().playerEntity;
        if (player != null && player.openContainer != null
                && player.openContainer instanceof ContainerPictureBook) {
            ContainerPictureBook contaner = (ContainerPictureBook) player.openContainer;
            if (contaner.getSlot(0).getHasStack() && contaner.getSlot(0).getStack().hasTagCompound()
                    && contaner.getSlot(0).getStack().getTagCompound().hasKey("pid")) {
                ItemStack itemStack = contaner.getSlot(0).getStack();
                String pid = itemStack.getTagCompound().getString("pid");
                if (contaner.getTotalPictureNum() <= 100) {
                    contaner.getListPid().add(pid);
                    contaner.setTotalPictureNum(contaner.getTotalPictureNum() + 1);
                    if (contaner.getTotalPictureNum() == 1) {
                        contaner.setIndex(0);
                    }
                } else {
                    player.addChatComponentMessage(new TextComponentTranslation("chat.picturebook.tomany"));
                    return null;
                }
            }
            contaner.getSlot(0).decrStackSize(64);
        }
    }
    return null;
}
项目:ToughExpansion    文件:PacketConfigSync.java   
private void handle(PacketConfigSync message, MessageContext ctx) {
    if (ctx.getClientHandler() != null) {
        Options.TEMP_REGULATOR_RADIUS = (Integer) message.values.get("TempRegulatorBlockRadius");
        Options.TEMP_REGULATOR_RF_CAPACITY = (Integer) message.values.get("TempRegulatorBlockRFCap");
        Options.THIRST_HEALTH_REGEN_FIX = (Boolean) message.values.get("ThirstHealthFix");
        Options.THIRST_QUENCHER_RF_CAPACITY = (Integer) message.values.get("ThirstQuencherRFCap");
        Options.PORTABLE_TEMP_REGULATOR_CAPACITY = (Integer) message.values.get("PortableTempRegulatorCap");
    }
}
项目:Mods    文件:TF2ContractHandler.java   
@Override
public IMessage onMessage(final ContractMessage message, MessageContext ctx) {

    if(Minecraft.getMinecraft().player==null)
        return null;
    ArrayList<Contract> contracts=Minecraft.getMinecraft().player.getCapability(TF2weapons.PLAYER_CAP, null).contracts;
    if(message.id==-1) {
        contracts.add(message.contract);
        Minecraft.getMinecraft().player.getCapability(TF2weapons.PLAYER_CAP, null).newContracts=true;
    }
    else if(contracts.size()<=message.id) {
        contracts.add(message.id, message.contract);
        if(message.contract.rewards>0) {
            Minecraft.getMinecraft().player.getCapability(TF2weapons.PLAYER_CAP, null).newRewards=true;
        }
    }
    else {
        Contract prev=contracts.set(message.id, message.contract);
        if(prev.rewards==0 && message.contract.rewards>0) {
            Minecraft.getMinecraft().player.getCapability(TF2weapons.PLAYER_CAP, null).newRewards=true;
        }
    }
    /*Minecraft.getMinecraft().addScheduledTask(new Runnable(){

        @Override
        public void run() {
            //System.out.println("Wep drop "+message.name);
            ItemStack stack=ItemFromData.getNewStack(message);
            ((ItemUsable)stack.getItem()).holster(Minecraft.getMinecraft().player.getCapability(TF2weapons.WEAPONS_CAP, null), stack, Minecraft.getMinecraft().player, Minecraft.getMinecraft().world);

        }

    });*/

    return null;
}
项目:PurificatiMagicae    文件:CPacketSpawnParticle.java   
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(CPacketSpawnParticle message, MessageContext ctx)
{
    Minecraft.getMinecraft().addScheduledTask(() ->
            Minecraft.getMinecraft().world.spawnParticle(message.type,
                    message.pos.getX(), message.pos.getY(), message.pos.getZ(),
                    message.motion.getX(), message.motion.getY(), message.motion.getZ()));
    return null;
}
项目:Minecoprocessors    文件:MessageBookCodeData.java   
@Override
protected void onMessageSynchronized(final MessageBookCodeData message, final MessageContext context) {
  final EntityPlayer player = context.getServerHandler().player;
  if (player != null) {
    final ItemStack stack = player.getHeldItem(EnumHand.MAIN_HAND);
    if (ItemBookCode.isBookCode(stack)) {
      final ItemBookCode.Data data = ItemBookCode.Data.loadFromNBT(message.getNbt());
      ItemBookCode.Data.saveToStack(stack, data);
    }
  }
}
项目:Mods    文件:TF2GuiConfigHandler.java   
@Override
public IMessage onMessage(final GuiConfigMessage message, final MessageContext ctx) {

    TF2weapons.server.addScheduledTask(new Runnable() {

        @Override
        public void run() {

            Entity ent = ctx.getServerHandler().player.world.getEntityByID(message.entityid);
            if (ent != null && ent instanceof EntityBuilding
                    && ((EntityBuilding) ent).getOwner() == ctx.getServerHandler().player) {
                if (message.id == 127) {
                    ((EntityBuilding) ent).grab();
                    return;
                }

                if (ent instanceof EntityTeleporter) {
                    if (message.id == 0)
                        ((EntityTeleporter) ent).setID(MathHelper.clamp(message.value,0,EntityTeleporter.TP_PER_PLAYER-1));
                    else if (message.id == 1)
                        ((EntityTeleporter) ent).setExit(message.value == 1);
                } else if (ent instanceof EntitySentry)
                    if (message.id == 0)
                        ((EntitySentry) ent).setTargetInfo(message.value);
            }
        }
    });

    return null;
}
项目:Minecoprocessors    文件:MessageEnableGuiUpdates.java   
@Override
public IMessage onMessage(final MessageEnableGuiUpdates message, MessageContext ctx) {
  if (message.pos == null) {
    return null;
  }
  final EntityPlayerMP payer = ctx.getServerHandler().player;
  payer.getServerWorld().addScheduledTask(new Worker(payer, message));
  return null;
}
项目:Never-Enough-Currency    文件:MessageSyncPrices.java   
@Override
public IMessage handleClientMessage(EntityPlayer player, MessageSyncPrices message, MessageContext ctx) {
    if ((player != null) && (message != null) && (ctx != null)) {
        EntityLivingBase en = (EntityLivingBase) player.getEntityWorld().getEntityByID(message.entityId);
        if (en != null) {
            if (en.getEntityWorld() != null && en.hasCapability(Currency.CART_DATA, null)) {
                CartCapability entityData = en.getCapability(Currency.CART_DATA, null);
                entityData.setPrices(message.prices, false);
            }
        }
    }
    return null;
}
项目:Proyecto-DASI    文件:InventoryCommandsImplementation.java   
@Override
public IMessage onMessage(InventoryMessage message, MessageContext ctx)
{
    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    if (message.combine)
        combineSlots(player, message.slotA, message.slotB);
    else
        swapSlots(player, message.slotA, message.slotB);
    return null;
}
项目:interactionwheel    文件:PacketPerformAction.java   
private void handle(PacketPerformAction message, MessageContext ctx) {
    IWheelAction action = InteractionWheel.registry.get(message.actionId);
    if (action != null) {
        EntityPlayerMP player = ctx.getServerHandler().player;
        action.performServer(player, player.getEntityWorld(), message.pos, message.extended);
    }
}
项目:PurificatiMagicae    文件:CPacketDisplayMessage.java   
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(CPacketDisplayMessage msg, MessageContext ctx)
{
    Minecraft.getMinecraft().addScheduledTask(() -> DisplayMessageQuery.addMessage(msg.msg));
    return null;
}
项目:ObsidianSuite    文件:MessageAnimationStart.java   
@Override
public IMessage onMessage(MessageAnimationStart message, MessageContext ctx) {
    Entity entity = Minecraft.getMinecraft().world.getEntityByID(message.entityID);
    if(entity != null) {
        ModelAnimated model = ((IRenderAnimated) Minecraft.getMinecraft().getRenderManager().getEntityRenderObject(entity)).getModel();
        EntityAnimationPropertiesClient animProps = EntityAnimationPropertiesClient.get(entity);
        if(animProps != null) 
            animProps.setActiveAnimation(model, message.animationName, System.currentTimeMillis(), message.loopAnim, message.transitionTime);
    }
    return null;
}
项目:PurificatiMagicae    文件:SPacketDoneTranslation.java   
@Override
public IMessage onMessage(SPacketDoneTranslation message, MessageContext ctx)
{
    EntityPlayerMP p = ctx.getServerHandler().player;
    p.getServerWorld().addScheduledTask(() ->
    {
        TileEntity te = p.getEntityWorld().getTileEntity(message.pos);
        if (te != null && te instanceof TileTranslationDesk)
        {
            TileTranslationDesk ttd = (TileTranslationDesk) te;
            ItemStack papyrus = ttd.handler.getStackInSlot(0);
            if (!papyrus.isEmpty())
            {
                IIfEntryStore store = p.getCapability(CapabilityRegistry.ENTRY_STORE_CAP, null);
                for (Pair<IfEntry, IRSTranslatePapyrus> pair : PurMag.INSTANCE.getIfRegistry().getAllResearchableSteps(IRSTranslatePapyrus.class, p, store))
                {
                    if (pair.getLeft().getId().equals(message.expected))
                    {
                        if (pair.getRight().isSuitable(papyrus))
                        {
                            store.unlockStepAndSync(pair.getLeft().getId(), ctx.getServerHandler().player);
                        }
                    }
                }
            }
        }
    });
    return null;
}
项目:RunicArcana    文件:PacketSendDust.java   
@Override
public IMessage onMessage(PacketSendDust message, MessageContext ctx) {
    // Always use a construct like this to actually handle your message. This ensures that
    // your 'handle' code is run on the main Minecraft thread. 'onMessage' itself
    // is called on the networking thread so it is not safe to do a lot of things
    // here.
    int breakP = 0;
    FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx));
    return null;
}
项目:RunicArcana    文件:PacketSendScrap.java   
@Override
public IMessage onMessage(PacketSendScrap message, MessageContext ctx) {
    // Always use a construct like this to actually handle your message. This ensures that
    // your 'handle' code is run on the main Minecraft thread. 'onMessage' itself
    // is called on the networking thread so it is not safe to do a lot of things
    // here.
    int breakP = 0;
    FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(() -> handle(message, ctx));
    return null;
}
项目:VanillaExtras    文件:PacketGetWorker.java   
@Override
public IMessage onMessage(PacketGetWorker message, MessageContext ctx) {
    if (!message.messageValid && ctx.side != Side.SERVER)
        return null;
    FMLCommonHandler.instance().getWorldThread(ctx.netHandler)
            .addScheduledTask(() -> processMessage(message, ctx));
    return null;
}
项目:uniquecrops    文件:PacketSendKey.java   
private void handle(PacketSendKey message, MessageContext ctx) {

    EntityPlayerMP player = ctx.getServerHandler().playerEntity;
    ItemStack glasses = player.inventory.armorInventory[3];
    if (glasses != null && glasses.getItem() == UCItems.pixelglasses)
        NBTUtils.setBoolean(glasses, "isActive", !glasses.getTagCompound().getBoolean("isActive"));
}
项目:customstuff4    文件:PacketSyncContainerFluid.java   
@Override
public IMessage onMessage(PacketSyncContainerFluid message, MessageContext ctx)
{
    EntityPlayer player = CustomStuff4.proxy.getClientPlayer();
    if (NetworkHelper.checkThreadAndEnqueue(message, this, ctx, Minecraft.getMinecraft()))
        return null;

    if (player.openContainer.windowId == message.windowId && (player.openContainer instanceof ContainerCS4))
    {
        ContainerCS4 container = (ContainerCS4) player.openContainer;
        container.putFluidInTank(message.tank, message.fluid);
    }

    return null;
}