Java 类net.minecraft.network.play.server.SPacketCustomPayload 实例源码

项目:Zombe-Modpack    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.world);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:Backmemed    文件:EntityPlayerMP.java   
public void openBook(ItemStack stack, EnumHand hand)
{
    Item item = stack.getItem();

    if (item == Items.WRITTEN_BOOK)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeEnumValue(hand);
        this.connection.sendPacket(new SPacketCustomPayload("MC|BOpen", packetbuffer));
    }
}
项目:Mods    文件:TF2EventsCommon.java   
@SubscribeEvent
public void containerOpen(PlayerContainerEvent.Open event) {
    if(!event.getEntityPlayer().world.isRemote && event.getContainer() instanceof ContainerMercenary) {
        IInventory iinventory = ((ContainerMerchant) event.getContainer()).getMerchantInventory();
        ITextComponent itextcomponent = ((ContainerMercenary) event.getContainer()).mercenary.getDisplayName();
        MerchantRecipeList merchantrecipelist =((ContainerMercenary) event.getContainer()).mercenary.getRecipes(event.getEntityPlayer());

        if (merchantrecipelist != null)
        {
            PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
            packetbuffer.writeInt(event.getContainer().windowId);
            merchantrecipelist.writeToBuf(packetbuffer);
            ((EntityPlayerMP)event.getEntityPlayer()).connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
        }
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
@Override
protected void channelRead0(ChannelHandlerContext ctx, Packet<?> msg) throws Exception
{
    boolean handled = false;
    if (msg instanceof CPacketCustomPayload)
    {
        handled = handleServerSideCustomPacket((CPacketCustomPayload) msg, ctx);
    }
    else if (msg instanceof SPacketCustomPayload)
    {
        handled = handleClientSideCustomPacket((SPacketCustomPayload)msg, ctx);
    }
    else if (state != ConnectionState.CONNECTED && state != ConnectionState.HANDSHAKECOMPLETE)
    {
        handled = handleVanilla(msg);
    }
    if (!handled)
    {
        ctx.fireChannelRead(msg);
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
public void displayVillagerTradeGui(IMerchant villager)
{
    this.getNextWindowId();
    this.openContainer = new ContainerMerchant(this.inventory, villager, this.worldObj);
    this.openContainer.windowId = this.currentWindowId;
    this.openContainer.addListener(this);
    net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.player.PlayerContainerEvent.Open(this, this.openContainer));
    IInventory iinventory = ((ContainerMerchant)this.openContainer).getMerchantInventory();
    ITextComponent itextcomponent = villager.getDisplayName();
    this.connection.sendPacket(new SPacketOpenWindow(this.currentWindowId, "minecraft:villager", itextcomponent, iinventory.getSizeInventory()));
    MerchantRecipeList merchantrecipelist = villager.getRecipes(this);

    if (merchantrecipelist != null)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeInt(this.currentWindowId);
        merchantrecipelist.writeToBuf(packetbuffer);
        this.connection.sendPacket(new SPacketCustomPayload("MC|TrList", packetbuffer));
    }
}
项目:ForgeHax    文件:PayloadSpoofer.java   
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onIncomingPacket(PacketEvent.Incoming.Pre event) {
    if(event.getPacket() instanceof SPacketCustomPayload) {
        String channel = ((SPacketCustomPayload) event.getPacket()).getChannelName();
        PacketBuffer packetBuffer = ((SPacketCustomPayload) event.getPacket()).getBufferData();
        if(isBlockedPacket(channel, packetBuffer)) event.setCanceled(true);
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
public void openBook(ItemStack stack, EnumHand hand)
{
    Item item = stack.getItem();

    if (item == Items.WRITTEN_BOOK)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeEnumValue(hand);
        this.connection.sendPacket(new SPacketCustomPayload("MC|BOpen", packetbuffer));
    }
}
项目:CustomWorldGen    文件:EntityPlayerMP.java   
public void openBook(ItemStack stack, EnumHand hand)
{
    Item item = stack.getItem();

    if (item == Items.WRITTEN_BOOK)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeEnumValue(hand);
        this.connection.sendPacket(new SPacketCustomPayload("MC|BOpen", packetbuffer));
    }
}
项目:GriefPrevention    文件:GPActor.java   
@Override
public void dispatchCUIEvent(CUIEvent event) {
    String[] params = event.getParameters();
    String send = event.getTypeId();
    if (params.length > 0) {
        send = send + "|" + StringUtil.joinString(params, "|");
    }

    PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(UTF_8_CHARSET)));
    SPacketCustomPayload packet = new SPacketCustomPayload(CUI_PLUGIN_CHANNEL, buffer);
    this.player.connection.sendPacket(packet);
}
项目:FastAsyncWorldedit    文件:ForgePlayer.java   
@Override
public void dispatchCUIEvent(CUIEvent event) {
    String[] params = event.getParameters();
    String send = event.getTypeId();
    if (params.length > 0) {
        send = send + "|" + StringUtil.joinString(params, "|");
    }
    PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)));
    SPacketCustomPayload packet = new SPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer);
    this.player.connection.sendPacket(packet);
}
项目:FastAsyncWorldedit    文件:ForgePlayer.java   
@Override
public void dispatchCUIEvent(CUIEvent event) {
    String[] params = event.getParameters();
    String send = event.getTypeId();
    if (params.length > 0) {
        send = send + "|" + StringUtil.joinString(params, "|");
    }
    PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)));
    SPacketCustomPayload packet = new SPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer);
    this.player.connection.sendPacket(packet);
}
项目:FastAsyncWorldedit    文件:ForgePlayer.java   
@Override
public void dispatchCUIEvent(CUIEvent event) {
    String[] params = event.getParameters();
    String send = event.getTypeId();
    if (params.length > 0) {
        send = send + "|" + StringUtil.joinString(params, "|");
    }
    PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)));
    SPacketCustomPayload packet = new SPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer);
    this.player.connection.sendPacket(packet);
}
项目:FastAsyncWorldedit    文件:ForgePlayer.java   
@Override
public void dispatchCUIEvent(CUIEvent event) {
    String[] params = event.getParameters();
    String send = event.getTypeId();
    if (params.length > 0) {
        send = send + "|" + StringUtil.joinString(params, "|");
    }
    PacketBuffer buffer = new PacketBuffer(Unpooled.copiedBuffer(send.getBytes(WECUIPacketHandler.UTF_8_CHARSET)));
    SPacketCustomPayload packet = new SPacketCustomPayload(ForgeWorldEdit.CUI_PLUGIN_CHANNEL, buffer);
    this.player.connection.sendPacket(packet);
}
项目:ExpandedRailsMod    文件:EntityPlayerMP.java   
public void openBook(ItemStack stack, EnumHand hand)
{
    Item item = stack.getItem();

    if (item == Items.WRITTEN_BOOK)
    {
        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeEnumValue(hand);
        this.connection.sendPacket(new SPacketCustomPayload("MC|BOpen", packetbuffer));
    }
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.player.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.player.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
        ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.player.getHeldItemOffhand() : this.gameController.player.getHeldItemMainhand();

        if (itemstack.getItem() == Items.WRITTEN_BOOK)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.player, itemstack, false));
        }
    }
    else if ("MC|DebugPath".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        int j = packetbuffer1.readInt();
        float f = packetbuffer1.readFloat();
        Path path = Path.read(packetbuffer1);
        ((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
    }
    else if ("MC|StopSound".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        String s = packetbuffer2.readStringFromBuffer(32767);
        String s1 = packetbuffer2.readStringFromBuffer(256);
        this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
    }
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.player.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.player.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
        ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.player.getHeldItemOffhand() : this.gameController.player.getHeldItemMainhand();

        if (itemstack.getItem() == Items.WRITTEN_BOOK)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.player, itemstack, false));
        }
    }
    else if ("MC|DebugPath".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        int j = packetbuffer1.readInt();
        float f = packetbuffer1.readFloat();
        Path path = Path.read(packetbuffer1);
        ((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
    }
    else if ("MC|DebugNeighborsUpdate".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        long k = packetbuffer2.readVarLong();
        BlockPos blockpos = packetbuffer2.readBlockPos();
        ((DebugRendererNeighborsUpdate)this.gameController.debugRenderer.field_191557_f).func_191553_a(k, blockpos);
    }
    else if ("MC|StopSound".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer3 = packetIn.getBufferData();
        String s = packetbuffer3.readStringFromBuffer(32767);
        String s1 = packetbuffer3.readStringFromBuffer(256);
        this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
    }
}
项目:Backmemed    文件:CommandStopSound.java   
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && args.length <= 3)
    {
        int i = 0;
        EntityPlayerMP entityplayermp = getPlayer(server, sender, args[i++]);
        String s = "";
        String s1 = "";

        if (args.length >= 2)
        {
            String s2 = args[i++];
            SoundCategory soundcategory = SoundCategory.getByName(s2);

            if (soundcategory == null)
            {
                throw new CommandException("commands.stopsound.unknownSoundSource", new Object[] {s2});
            }

            s = soundcategory.getName();
        }

        if (args.length == 3)
        {
            s1 = args[i++];
        }

        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeString(s);
        packetbuffer.writeString(s1);
        entityplayermp.connection.sendPacket(new SPacketCustomPayload("MC|StopSound", packetbuffer));

        if (s.isEmpty() && s1.isEmpty())
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.all", new Object[] {entityplayermp.getName()});
        }
        else if (s1.isEmpty())
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.soundSource", new Object[] {s, entityplayermp.getName()});
        }
        else
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.individualSound", new Object[] {s1, s, entityplayermp.getName()});
        }
    }
    else
    {
        throw new WrongUsageException(this.getCommandUsage(sender), new Object[0]);
    }
}
项目:CustomWorldGen    文件:FMLProxyPacket.java   
public FMLProxyPacket(SPacketCustomPayload original)
{
    this(original.getBufferData(), original.getChannelName());
    this.target = Side.CLIENT;
}
项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.thePlayer.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
        ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.thePlayer.getHeldItemOffhand() : this.gameController.thePlayer.getHeldItemMainhand();

        if (itemstack != null && itemstack.getItem() == Items.WRITTEN_BOOK)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
        }
    }
    else if ("MC|DebugPath".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        int j = packetbuffer1.readInt();
        float f = packetbuffer1.readFloat();
        Path path = Path.read(packetbuffer1);
        ((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
    }
    else if ("MC|StopSound".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        String s = packetbuffer2.readStringFromBuffer(32767);
        String s1 = packetbuffer2.readStringFromBuffer(256);
        this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
    }
}
项目:CustomWorldGen    文件:CommandStopSound.java   
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && args.length <= 3)
    {
        int i = 0;
        EntityPlayerMP entityplayermp = getPlayer(server, sender, args[i++]);
        String s = "";
        String s1 = "";

        if (args.length >= 2)
        {
            String s2 = args[i++];
            SoundCategory soundcategory = SoundCategory.getByName(s2);

            if (soundcategory == null)
            {
                throw new CommandException("commands.stopsound.unknownSoundSource", new Object[] {s2});
            }

            s = soundcategory.getName();
        }

        if (args.length == 3)
        {
            s1 = args[i++];
        }

        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeString(s);
        packetbuffer.writeString(s1);
        entityplayermp.connection.sendPacket(new SPacketCustomPayload("MC|StopSound", packetbuffer));

        if (s.isEmpty() && s1.isEmpty())
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.all", new Object[] {entityplayermp.getName()});
        }
        else if (s1.isEmpty())
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.soundSource", new Object[] {s, entityplayermp.getName()});
        }
        else
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.individualSound", new Object[] {s1, s, entityplayermp.getName()});
        }
    }
    else
    {
        throw new WrongUsageException(this.getCommandUsage(sender), new Object[0]);
    }
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
public void handleCustomPayload(SPacketCustomPayload packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if ("MC|TrList".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer = packetIn.getBufferData();

        try
        {
            int i = packetbuffer.readInt();
            GuiScreen guiscreen = this.gameController.currentScreen;

            if (guiscreen != null && guiscreen instanceof GuiMerchant && i == this.gameController.thePlayer.openContainer.windowId)
            {
                IMerchant imerchant = ((GuiMerchant)guiscreen).getMerchant();
                MerchantRecipeList merchantrecipelist = MerchantRecipeList.readFromBuf(packetbuffer);
                imerchant.setRecipes(merchantrecipelist);
            }
        }
        catch (IOException ioexception)
        {
            LOGGER.error((String)"Couldn\'t load trade info", (Throwable)ioexception);
        }
        finally
        {
            packetbuffer.release();
        }
    }
    else if ("MC|Brand".equals(packetIn.getChannelName()))
    {
        this.gameController.thePlayer.setServerBrand(packetIn.getBufferData().readStringFromBuffer(32767));
    }
    else if ("MC|BOpen".equals(packetIn.getChannelName()))
    {
        EnumHand enumhand = (EnumHand)packetIn.getBufferData().readEnumValue(EnumHand.class);
        ItemStack itemstack = enumhand == EnumHand.OFF_HAND ? this.gameController.thePlayer.getHeldItemOffhand() : this.gameController.thePlayer.getHeldItemMainhand();

        if (itemstack != null && itemstack.getItem() == Items.WRITTEN_BOOK)
        {
            this.gameController.displayGuiScreen(new GuiScreenBook(this.gameController.thePlayer, itemstack, false));
        }
    }
    else if ("MC|DebugPath".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer1 = packetIn.getBufferData();
        int j = packetbuffer1.readInt();
        float f = packetbuffer1.readFloat();
        Path path = Path.read(packetbuffer1);
        ((DebugRendererPathfinding)this.gameController.debugRenderer.debugRendererPathfinding).addPath(j, path, f);
    }
    else if ("MC|StopSound".equals(packetIn.getChannelName()))
    {
        PacketBuffer packetbuffer2 = packetIn.getBufferData();
        String s = packetbuffer2.readStringFromBuffer(32767);
        String s1 = packetbuffer2.readStringFromBuffer(256);
        this.gameController.getSoundHandler().stop(s1, SoundCategory.getByName(s));
    }
}
项目:ExpandedRailsMod    文件:CommandStopSound.java   
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length >= 1 && args.length <= 3)
    {
        int i = 0;
        EntityPlayerMP entityplayermp = getPlayer(server, sender, args[i++]);
        String s = "";
        String s1 = "";

        if (args.length >= 2)
        {
            String s2 = args[i++];
            SoundCategory soundcategory = SoundCategory.getByName(s2);

            if (soundcategory == null)
            {
                throw new CommandException("commands.stopsound.unknownSoundSource", new Object[] {s2});
            }

            s = soundcategory.getName();
        }

        if (args.length == 3)
        {
            s1 = args[i++];
        }

        PacketBuffer packetbuffer = new PacketBuffer(Unpooled.buffer());
        packetbuffer.writeString(s);
        packetbuffer.writeString(s1);
        entityplayermp.connection.sendPacket(new SPacketCustomPayload("MC|StopSound", packetbuffer));

        if (s.isEmpty() && s1.isEmpty())
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.all", new Object[] {entityplayermp.getName()});
        }
        else if (s1.isEmpty())
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.soundSource", new Object[] {s, entityplayermp.getName()});
        }
        else
        {
            notifyCommandListener(sender, this, "commands.stopsound.success.individualSound", new Object[] {s1, s, entityplayermp.getName()});
        }
    }
    else
    {
        throw new WrongUsageException(this.getCommandUsage(sender), new Object[0]);
    }
}
项目:Backmemed    文件:INetHandlerPlayClient.java   
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
void handleCustomPayload(SPacketCustomPayload packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
/**
 * Handles packets that have room for a channel specification. Vanilla implemented channels are "MC|TrList" to
 * acquire a MerchantRecipeList trades for a villager merchant, "MC|Brand" which sets the server brand? on the
 * player instance and finally "MC|RPack" which the server uses to communicate the identifier of the default server
 * resourcepack for the client to load.
 */
void handleCustomPayload(SPacketCustomPayload packetIn);