• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SPacketCustomPayload类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.minecraft.network.play.server.SPacketCustomPayload的典型用法代码示例。如果您正苦于以下问题:Java SPacketCustomPayload类的具体用法?Java SPacketCustomPayload怎么用?Java SPacketCustomPayload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



SPacketCustomPayload类属于net.minecraft.network.play.server包,在下文中一共展示了SPacketCustomPayload类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: displayVillagerTradeGui

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
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));
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:20,代码来源:EntityPlayerMP.java


示例2: openBook

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
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));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:12,代码来源:EntityPlayerMP.java


示例3: containerOpen

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
@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));
        }
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:17,代码来源:TF2EventsCommon.java


示例4: channelRead0

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:22,代码来源:NetworkDispatcher.java


示例5: displayVillagerTradeGui

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
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));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:21,代码来源:EntityPlayerMP.java


示例6: onIncomingPacket

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
@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);
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:9,代码来源:PayloadSpoofer.java


示例7: dispatchCUIEvent

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
@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);
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:13,代码来源:GPActor.java


示例8: dispatchCUIEvent

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
@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);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:12,代码来源:ForgePlayer.java


示例9: handleCustomPayload

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
/**
 * 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));
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:66,代码来源:NetHandlerPlayClient.java


示例10: handleCustomPayload

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
/**
 * 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));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:73,代码来源:NetHandlerPlayClient.java


示例11: execute

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
/**
 * 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]);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:54,代码来源:CommandStopSound.java


示例12: FMLProxyPacket

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
public FMLProxyPacket(SPacketCustomPayload original)
{
    this(original.getBufferData(), original.getChannelName());
    this.target = Side.CLIENT;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:6,代码来源:FMLProxyPacket.java


示例13: handleCustomPayload

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
/**
 * 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));
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:66,代码来源:NetHandlerPlayClient.java


示例14: handleCustomPayload

import net.minecraft.network.play.server.SPacketCustomPayload; //导入依赖的package包/类
/**
 * 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);
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:8,代码来源:INetHandlerPlayClient.java



注:本文中的net.minecraft.network.play.server.SPacketCustomPayload类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java WalkingRoutePlanOption类代码示例发布时间:2022-05-23
下一篇:
Java Join类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap