當前位置: 首頁>>代碼示例>>Java>>正文


Java Packet類代碼示例

本文整理匯總了Java中net.minecraft.network.Packet的典型用法代碼示例。如果您正苦於以下問題:Java Packet類的具體用法?Java Packet怎麽用?Java Packet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Packet類屬於net.minecraft.network包,在下文中一共展示了Packet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendScoreboard

import net.minecraft.network.Packet; //導入依賴的package包/類
protected void sendScoreboard(ServerScoreboard scoreboardIn, EntityPlayerMP playerIn)
{
    Set<ScoreObjective> set = Sets.<ScoreObjective>newHashSet();

    for (ScorePlayerTeam scoreplayerteam : scoreboardIn.getTeams())
    {
        playerIn.connection.sendPacket(new SPacketTeams(scoreplayerteam, 0));
    }

    for (int i = 0; i < 19; ++i)
    {
        ScoreObjective scoreobjective = scoreboardIn.getObjectiveInDisplaySlot(i);

        if (scoreobjective != null && !set.contains(scoreobjective))
        {
            for (Packet<?> packet : scoreboardIn.getCreatePackets(scoreobjective))
            {
                playerIn.connection.sendPacket(packet);
            }

            set.add(scoreobjective);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:PlayerList.java

示例2: sendToAllNearExcept

import net.minecraft.network.Packet; //導入依賴的package包/類
/**
 * params: srcPlayer,x,y,z,r,dimension. The packet is not sent to the srcPlayer, but all other players within the
 * search radius
 */
public void sendToAllNearExcept(EntityPlayer p_148543_1_, double x, double y, double z, double radius, int dimension, Packet p_148543_11_)
{
    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i);

        if (entityplayermp != p_148543_1_ && entityplayermp.dimension == dimension)
        {
            double d0 = x - entityplayermp.posX;
            double d1 = y - entityplayermp.posY;
            double d2 = z - entityplayermp.posZ;

            if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius)
            {
                entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
            }
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:24,代碼來源:ServerConfigurationManager.java

示例3: write

import net.minecraft.network.Packet; //導入依賴的package包/類
@Override
public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception
{
    if (msg instanceof FMLProxyPacket)
    {
        if (side == Side.CLIENT)
        {
            //Client to server large packets are not supported to prevent client being bad.
            ctx.write(((FMLProxyPacket) msg).toC17Packet(), promise);
        }
        else
        {
            List<Packet<INetHandlerPlayClient>> parts = ((FMLProxyPacket)msg).toS3FPackets();
            for (Packet<INetHandlerPlayClient> pkt : parts)
            {
                ctx.write(pkt, promise);
            }
        }
    }
    else
    {
        ctx.write(msg, promise);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:NetworkDispatcher.java

示例4: sendToAllNearExcept

import net.minecraft.network.Packet; //導入依賴的package包/類
/**
 * params: srcPlayer,x,y,z,r,dimension. The packet is not sent to the srcPlayer, but all other players within the
 * search radius
 */
public void sendToAllNearExcept(@Nullable EntityPlayer except, double x, double y, double z, double radius, int dimension, Packet<?> packetIn)
{
    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i);

        if (entityplayermp != except && entityplayermp.dimension == dimension)
        {
            double d0 = x - entityplayermp.posX;
            double d1 = y - entityplayermp.posY;
            double d2 = z - entityplayermp.posZ;

            if (d0 * d0 + d1 * d1 + d2 * d2 < radius * radius)
            {
                entityplayermp.connection.sendPacket(packetIn);
            }
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:24,代碼來源:PlayerList.java

示例5: sendScoreboard

import net.minecraft.network.Packet; //導入依賴的package包/類
protected void sendScoreboard(ServerScoreboard scoreboardIn, EntityPlayerMP playerIn)
{
    Set<ScoreObjective> set = Sets.<ScoreObjective>newHashSet();

    for (ScorePlayerTeam scoreplayerteam : scoreboardIn.getTeams())
    {
        playerIn.playerNetServerHandler.sendPacket(new S3EPacketTeams(scoreplayerteam, 0));
    }

    for (int i = 0; i < 19; ++i)
    {
        ScoreObjective scoreobjective = scoreboardIn.getObjectiveInDisplaySlot(i);

        if (scoreobjective != null && !set.contains(scoreobjective))
        {
            for (Packet packet : scoreboardIn.func_96550_d(scoreobjective))
            {
                playerIn.playerNetServerHandler.sendPacket(packet);
            }

            set.add(scoreobjective);
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:25,代碼來源:ServerConfigurationManager.java

示例6: sendPacketToTrackedPlayers

import net.minecraft.network.Packet; //導入依賴的package包/類
/**
 * Send the given packet to all players tracking this entity.
 */
public void sendPacketToTrackedPlayers(Packet packetIn)
{
    for (EntityPlayerMP entityplayermp : this.trackingPlayers)
    {
        entityplayermp.playerNetServerHandler.sendPacket(packetIn);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:EntityTrackerEntry.java

示例7: getDescriptionPacket

import net.minecraft.network.Packet; //導入依賴的package包/類
/**
 * Allows for a specialized description packet to be created. This is often used to sync tile entity data from the
 * server to the client easily. For example this is used by signs to synchronise the text to be displayed.
 */
public Packet getDescriptionPacket()
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    this.writeToNBT(nbttagcompound);
    nbttagcompound.removeTag("Item");
    nbttagcompound.setInteger("Item", Item.getIdFromItem(this.flowerPotItem));
    return new S35PacketUpdateTileEntity(this.pos, 5, nbttagcompound);
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:13,代碼來源:TileEntityFlowerPot.java

示例8: func_151248_b

import net.minecraft.network.Packet; //導入依賴的package包/類
public void func_151248_b(Entity entityIn, Packet p_151248_2_)
{
    EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityHashTable.lookup(entityIn.getEntityId());

    if (entitytrackerentry != null)
    {
        entitytrackerentry.func_151261_b(p_151248_2_);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:10,代碼來源:EntityTracker.java

示例9: func_96548_f

import net.minecraft.network.Packet; //導入依賴的package包/類
public List<Packet> func_96548_f(ScoreObjective p_96548_1_)
{
    List<Packet> list = Lists.<Packet>newArrayList();
    list.add(new S3BPacketScoreboardObjective(p_96548_1_, 1));

    for (int i = 0; i < 19; ++i)
    {
        if (this.getObjectiveInDisplaySlot(i) == p_96548_1_)
        {
            list.add(new S3DPacketDisplayScoreboard(i, p_96548_1_));
        }
    }

    return list;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:16,代碼來源:ServerScoreboard.java

示例10: getPacket

import net.minecraft.network.Packet; //導入依賴的package包/類
@Nullable
public Packet<?> getPacket(ItemStack stack)
{
    if (this.isDirty)
    {
        this.isDirty = false;
        return new SPacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.trackingPosition, MapData.this.mapDecorations.values(), MapData.this.colors, this.minX, this.minY, this.maxX + 1 - this.minX, this.maxY + 1 - this.minY);
    }
    else
    {
        return this.tick++ % 5 == 0 ? new SPacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.trackingPosition, MapData.this.mapDecorations.values(), MapData.this.colors, 0, 0, 0, 0) : null;
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:14,代碼來源:MapData.java

示例11: encode

import net.minecraft.network.Packet; //導入依賴的package包/類
protected void encode(ChannelHandlerContext p_encode_1_, Packet p_encode_2_, ByteBuf p_encode_3_) throws IOException, Exception
{
    Integer integer = ((EnumConnectionState)p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacketId(this.direction, p_encode_2_);

    if (logger.isDebugEnabled())
    {
        logger.debug(RECEIVED_PACKET_MARKER, "OUT: [{}:{}] {}", new Object[] {p_encode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), integer, p_encode_2_.getClass().getName()});
    }

    if (integer == null)
    {
        throw new IOException("Can\'t serialize unregistered packet");
    }
    else
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_encode_3_);
        packetbuffer.writeVarIntToBuffer(integer.intValue());

        try
        {
            p_encode_2_.writePacketData(packetbuffer);
        }
        catch (Throwable throwable)
        {
            logger.error((Object)throwable);
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:29,代碼來源:MessageSerializer.java

示例12: sendToAllPlayersWatchingChunk

import net.minecraft.network.Packet; //導入依賴的package包/類
public void sendToAllPlayersWatchingChunk(Packet thePacket)
{
    for (int i = 0; i < this.playersWatchingChunk.size(); ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playersWatchingChunk.get(i);

        if (!entityplayermp.loadedChunks.contains(this.chunkCoords))
        {
            entityplayermp.playerNetServerHandler.sendPacket(thePacket);
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:13,代碼來源:PlayerManager.java

示例13: onUpdate

import net.minecraft.network.Packet; //導入依賴的package包/類
@EventTarget(value=4)
private void onUpdate(UpdateEvent event) {
    if (this.mc.thePlayer.isBlocking() && (this.mc.thePlayer.motionX != 0.0 || this.mc.thePlayer.motionZ != 0.0)) {
        if (event.state == Event.State.PRE) {
            this.mc.getNetHandler().getNetworkManager().dispatchPacket((Packet)new C07PacketPlayerDigging(C07PacketPlayerDigging.Action.RELEASE_USE_ITEM, BlockPos.ORIGIN, EnumFacing.DOWN), null);
        } else if (event.state == Event.State.POST) {
            this.mc.thePlayer.sendQueue.addToSendQueue((Packet)new C08PacketPlayerBlockPlacement(this.mc.thePlayer.inventory.getCurrentItem()));
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:11,代碼來源:NoSlowdown.java

示例14: sendToAllTrackingEntity

import net.minecraft.network.Packet; //導入依賴的package包/類
public void sendToAllTrackingEntity(Entity entityIn, Packet<?> packetIn)
{
    EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityHashTable.lookup(entityIn.getEntityId());

    if (entitytrackerentry != null)
    {
        entitytrackerentry.sendPacketToTrackedPlayers(packetIn);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:10,代碼來源:EntityTracker.java

示例15: getPacket

import net.minecraft.network.Packet; //導入依賴的package包/類
public Packet<?> getPacket(ItemStack stack)
{
    if (this.isDirty)
    {
        this.isDirty = false;
        return new SPacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.trackingPosition, MapData.this.mapDecorations.values(), MapData.this.colors, this.minX, this.minY, this.maxX + 1 - this.minX, this.maxY + 1 - this.minY);
    }
    else
    {
        return this.tick++ % 5 == 0 ? new SPacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.trackingPosition, MapData.this.mapDecorations.values(), MapData.this.colors, 0, 0, 0, 0) : null;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:13,代碼來源:MapData.java


注:本文中的net.minecraft.network.Packet類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。