当前位置: 首页>>代码示例>>Java>>正文


Java PacketBuffer.readVarLong方法代码示例

本文整理汇总了Java中net.minecraft.network.PacketBuffer.readVarLong方法的典型用法代码示例。如果您正苦于以下问题:Java PacketBuffer.readVarLong方法的具体用法?Java PacketBuffer.readVarLong怎么用?Java PacketBuffer.readVarLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.network.PacketBuffer的用法示例。


在下文中一共展示了PacketBuffer.readVarLong方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readPacketData

import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.action = (SPacketWorldBorder.Action)buf.readEnumValue(SPacketWorldBorder.Action.class);

    switch (this.action)
    {
        case SET_SIZE:
            this.targetSize = buf.readDouble();
            break;
        case LERP_SIZE:
            this.diameter = buf.readDouble();
            this.targetSize = buf.readDouble();
            this.timeUntilTarget = buf.readVarLong();
            break;
        case SET_CENTER:
            this.centerX = buf.readDouble();
            this.centerZ = buf.readDouble();
            break;
        case SET_WARNING_BLOCKS:
            this.warningDistance = buf.readVarIntFromBuffer();
            break;
        case SET_WARNING_TIME:
            this.warningTime = buf.readVarIntFromBuffer();
            break;
        case INITIALIZE:
            this.centerX = buf.readDouble();
            this.centerZ = buf.readDouble();
            this.diameter = buf.readDouble();
            this.targetSize = buf.readDouble();
            this.timeUntilTarget = buf.readVarLong();
            this.size = buf.readVarIntFromBuffer();
            this.warningDistance = buf.readVarIntFromBuffer();
            this.warningTime = buf.readVarIntFromBuffer();
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:39,代码来源:SPacketWorldBorder.java

示例2: readPacketData

import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.action = (S44PacketWorldBorder.Action)buf.readEnumValue(S44PacketWorldBorder.Action.class);

    switch (this.action)
    {
        case SET_SIZE:
            this.targetSize = buf.readDouble();
            break;

        case LERP_SIZE:
            this.diameter = buf.readDouble();
            this.targetSize = buf.readDouble();
            this.timeUntilTarget = buf.readVarLong();
            break;

        case SET_CENTER:
            this.centerX = buf.readDouble();
            this.centerZ = buf.readDouble();
            break;

        case SET_WARNING_BLOCKS:
            this.warningDistance = buf.readVarIntFromBuffer();
            break;

        case SET_WARNING_TIME:
            this.warningTime = buf.readVarIntFromBuffer();
            break;

        case INITIALIZE:
            this.centerX = buf.readDouble();
            this.centerZ = buf.readDouble();
            this.diameter = buf.readDouble();
            this.targetSize = buf.readDouble();
            this.timeUntilTarget = buf.readVarLong();
            this.size = buf.readVarIntFromBuffer();
            this.warningDistance = buf.readVarIntFromBuffer();
            this.warningTime = buf.readVarIntFromBuffer();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:44,代码来源:S44PacketWorldBorder.java

示例3: readPacketData

import net.minecraft.network.PacketBuffer; //导入方法依赖的package包/类
/**
 * Reads the raw packet data from the data stream.
 */
public void readPacketData(PacketBuffer buf) throws IOException
{
    this.action = (SPacketWorldBorder.Action)buf.readEnumValue(SPacketWorldBorder.Action.class);

    switch (this.action)
    {
        case SET_SIZE:
            this.targetSize = buf.readDouble();
            break;

        case LERP_SIZE:
            this.diameter = buf.readDouble();
            this.targetSize = buf.readDouble();
            this.timeUntilTarget = buf.readVarLong();
            break;

        case SET_CENTER:
            this.centerX = buf.readDouble();
            this.centerZ = buf.readDouble();
            break;

        case SET_WARNING_BLOCKS:
            this.warningDistance = buf.readVarIntFromBuffer();
            break;

        case SET_WARNING_TIME:
            this.warningTime = buf.readVarIntFromBuffer();
            break;

        case INITIALIZE:
            this.centerX = buf.readDouble();
            this.centerZ = buf.readDouble();
            this.diameter = buf.readDouble();
            this.targetSize = buf.readDouble();
            this.timeUntilTarget = buf.readVarLong();
            this.size = buf.readVarIntFromBuffer();
            this.warningDistance = buf.readVarIntFromBuffer();
            this.warningTime = buf.readVarIntFromBuffer();
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:44,代码来源:SPacketWorldBorder.java

示例4: handleCustomPayload

import net.minecraft.network.PacketBuffer; //导入方法依赖的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


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