Java 类net.minecraft.network.Packet 实例源码

项目:CustomWorldGen    文件:PlayerList.java   
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);
        }
    }
}
项目:BaseClient    文件:ServerConfigurationManager.java   
/**
 * 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_);
            }
        }
    }
}
项目:CustomWorldGen    文件:NetworkDispatcher.java   
@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);
    }
}
项目:Backmemed    文件:PlayerList.java   
/**
 * 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);
            }
        }
    }
}
项目:DecompiledMinecraft    文件:ServerConfigurationManager.java   
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);
        }
    }
}
项目:BaseClient    文件:EntityTrackerEntry.java   
/**
 * Send the given packet to all players tracking this entity.
 */
public void sendPacketToTrackedPlayers(Packet packetIn)
{
    for (EntityPlayerMP entityplayermp : this.trackingPlayers)
    {
        entityplayermp.playerNetServerHandler.sendPacket(packetIn);
    }
}
项目:BaseClient    文件:TileEntityFlowerPot.java   
/**
 * 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);
}
项目:BaseClient    文件:EntityTracker.java   
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_);
    }
}
项目:DecompiledMinecraft    文件:ServerScoreboard.java   
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;
}
项目:Backmemed    文件:MapData.java   
@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;
    }
}
项目:BaseClient    文件:MessageSerializer.java   
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);
        }
    }
}
项目:BaseClient    文件:PlayerManager.java   
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);
        }
    }
}
项目:BaseClient    文件:MessageSerializer.java   
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);
        }
    }
}
项目:BaseClient    文件:NoSlowdown.java   
@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()));
        }
    }
}
项目:Backmemed    文件:EntityTracker.java   
public void sendToAllTrackingEntity(Entity entityIn, Packet<?> packetIn)
{
    EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityHashTable.lookup(entityIn.getEntityId());

    if (entitytrackerentry != null)
    {
        entitytrackerentry.sendPacketToTrackedPlayers(packetIn);
    }
}
项目:CustomWorldGen    文件:MapData.java   
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;
    }
}
项目:Backmemed    文件:PlayerChunkMapEntry.java   
public boolean sendToPlayers()
{
    if (this.sentToPlayers)
    {
        return true;
    }
    else if (this.chunk == null)
    {
        return false;
    }
    else if (!this.chunk.isPopulated())
    {
        return false;
    }
    else
    {
        this.changes = 0;
        this.changedSectionFilter = 0;
        this.sentToPlayers = true;
        Packet<?> packet = new SPacketChunkData(this.chunk, 65535);

        for (EntityPlayerMP entityplayermp : this.players)
        {
            entityplayermp.connection.sendPacket(packet);
            this.playerChunkMap.getWorldServer().getEntityTracker().sendLeashedEntitiesInChunk(entityplayermp, this.chunk);
        }

        return true;
    }
}
项目:ForgeHax    文件:PacketLogger.java   
private static void logPacket(FileOutputStream stream, Packet<?> packet) {
    if (stream == null || packet == null) return;

    try {
        stream.write(String.format(
                "[%s][%s] %s\n",
                TIME_FORMAT.format(new Date()),
                packet.getClass().getSimpleName(),
                GSON_PRETTY.toJson(objectToElement(packet, true, null, Lists.newArrayList()))).getBytes()
        );
    } catch (Throwable t) {
        t.printStackTrace();
    }
}
项目:BaseClient    文件:MapData.java   
public Packet getPacket(ItemStack stack)
{
    if (this.field_176105_d)
    {
        this.field_176105_d = false;
        return new S34PacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.mapDecorations.values(), MapData.this.colors, this.minX, this.minY, this.maxX + 1 - this.minX, this.maxY + 1 - this.minY);
    }
    else
    {
        return this.field_176109_i++ % 5 == 0 ? new S34PacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.mapDecorations.values(), MapData.this.colors, 0, 0, 0, 0) : null;
    }
}
项目:TFCPrimitiveTech    文件:TileEntityWoodenPressWet.java   
@Override
public Packet getDescriptionPacket()
{
    NBTTagCompound nbt = new NBTTagCompound();
    writeToNBT(nbt);
    return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbt);
}
项目:DecompiledMinecraft    文件:MapData.java   
public Packet getPacket(ItemStack stack)
{
    if (this.field_176105_d)
    {
        this.field_176105_d = false;
        return new S34PacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.mapDecorations.values(), MapData.this.colors, this.minX, this.minY, this.maxX + 1 - this.minX, this.maxY + 1 - this.minY);
    }
    else
    {
        return this.field_176109_i++ % 5 == 0 ? new S34PacketMaps(stack.getMetadata(), MapData.this.scale, MapData.this.mapDecorations.values(), MapData.this.colors, 0, 0, 0, 0) : null;
    }
}
项目:DecompiledMinecraft    文件:EntityTrackerEntry.java   
/**
 * Send the given packet to all players tracking this entity.
 */
public void sendPacketToTrackedPlayers(Packet packetIn)
{
    for (EntityPlayerMP entityplayermp : this.trackingPlayers)
    {
        entityplayermp.playerNetServerHandler.sendPacket(packetIn);
    }
}
项目:DecompiledMinecraft    文件:EntityTrackerEntry.java   
public void func_151261_b(Packet packetIn)
{
    this.sendPacketToTrackedPlayers(packetIn);

    if (this.trackedEntity instanceof EntityPlayerMP)
    {
        ((EntityPlayerMP)this.trackedEntity).playerNetServerHandler.sendPacket(packetIn);
    }
}
项目:BaseClient    文件:TileEntitySign.java   
/**
 * 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()
{
    IChatComponent[] aichatcomponent = new IChatComponent[4];
    System.arraycopy(this.signText, 0, aichatcomponent, 0, 4);
    return new S33PacketUpdateSign(this.worldObj, this.pos, aichatcomponent);
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
public EntityPlayer.EnumStatus trySleep(BlockPos bedLocation)
{
    EntityPlayer.EnumStatus entityplayer$enumstatus = super.trySleep(bedLocation);

    if (entityplayer$enumstatus == EntityPlayer.EnumStatus.OK)
    {
        Packet packet = new S0APacketUseBed(this, bedLocation);
        this.getServerForPlayer().getEntityTracker().sendToAllTrackingEntity(this, packet);
        this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
        this.playerNetServerHandler.sendPacket(packet);
    }

    return entityplayer$enumstatus;
}
项目:DecompiledMinecraft    文件:EntityTracker.java   
public void sendToAllTrackingEntity(Entity entityIn, Packet p_151247_2_)
{
    EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityHashTable.lookup(entityIn.getEntityId());

    if (entitytrackerentry != null)
    {
        entitytrackerentry.sendPacketToTrackedPlayers(p_151247_2_);
    }
}
项目:FundamentalChemistry    文件:TileLaserRelay.java   
@Override
public Packet getDescriptionPacket() 
{
  NBTTagCompound tag = new NBTTagCompound();
  writeToNBT(tag);
  return new S35PacketUpdateTileEntity(this.pos, 1, tag);
}
项目:BaseClient    文件:EntityTracker.java   
public void sendToAllTrackingEntity(Entity entityIn, Packet p_151247_2_)
{
    EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityHashTable.lookup(entityIn.getEntityId());

    if (entitytrackerentry != null)
    {
        entitytrackerentry.sendPacketToTrackedPlayers(p_151247_2_);
    }
}
项目:Backmemed    文件:PlayerList.java   
public void sendPacketToAllPlayers(Packet<?> packetIn)
{
    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        ((EntityPlayerMP)this.playerEntityList.get(i)).connection.sendPacket(packetIn);
    }
}
项目:Zombe-Modpack    文件:EntityPlayerMP.java   
public EntityPlayer.SleepResult trySleep(BlockPos bedLocation)
{
    EntityPlayer.SleepResult entityplayer$sleepresult = super.trySleep(bedLocation);

    if (entityplayer$sleepresult == EntityPlayer.SleepResult.OK)
    {
        this.addStat(StatList.SLEEP_IN_BED);
        Packet<?> packet = new SPacketUseBed(this, bedLocation);
        this.getServerWorld().getEntityTracker().sendToAllTrackingEntity(this, packet);
        this.connection.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
        this.connection.sendPacket(packet);
    }

    return entityplayer$sleepresult;
}
项目:DecompiledMinecraft    文件:MessageDeserializer.java   
protected void decode(ChannelHandlerContext p_decode_1_, ByteBuf p_decode_2_, List<Object> p_decode_3_) throws IOException, InstantiationException, IllegalAccessException, Exception
{
    if (p_decode_2_.readableBytes() != 0)
    {
        PacketBuffer packetbuffer = new PacketBuffer(p_decode_2_);
        int i = packetbuffer.readVarIntFromBuffer();
        Packet packet = ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getPacket(this.direction, i);

        if (packet == null)
        {
            throw new IOException("Bad packet id " + i);
        }
        else
        {
            packet.readPacketData(packetbuffer);

            if (packetbuffer.readableBytes() > 0)
            {
                throw new IOException("Packet " + ((EnumConnectionState)p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get()).getId() + "/" + i + " (" + packet.getClass().getSimpleName() + ") was larger than I expected, found " + packetbuffer.readableBytes() + " bytes extra whilst reading packet " + i);
            }
            else
            {
                p_decode_3_.add(packet);

                if (logger.isDebugEnabled())
                {
                    logger.debug(RECEIVED_PACKET_MARKER, " IN: [{}:{}] {}", new Object[] {p_decode_1_.channel().attr(NetworkManager.attrKeyConnectionState).get(), Integer.valueOf(i), packet.getClass().getName()});
                }
            }
        }
    }
}
项目:Backmemed    文件:PlayerList.java   
public void sendPacketToAllPlayersInDimension(Packet<?> packetIn, int dimension)
{
    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(i);

        if (entityplayermp.dimension == dimension)
        {
            entityplayermp.connection.sendPacket(packetIn);
        }
    }
}
项目:BaseClient    文件:ServerScoreboard.java   
public void getPlayerIterator(ScoreObjective p_96546_1_)
{
    List<Packet> list = this.func_96548_f(p_96546_1_);

    for (EntityPlayerMP entityplayermp : this.scoreboardMCServer.getConfigurationManager().func_181057_v())
    {
        for (Packet packet : list)
        {
            entityplayermp.playerNetServerHandler.sendPacket(packet);
        }
    }

    this.field_96553_b.remove(p_96546_1_);
}
项目:DecompiledMinecraft    文件:TileEntitySkull.java   
/**
 * 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);
    return new S35PacketUpdateTileEntity(this.pos, 4, nbttagcompound);
}
项目:DecompiledMinecraft    文件:TileEntityBeacon.java   
/**
 * 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);
    return new S35PacketUpdateTileEntity(this.pos, 3, nbttagcompound);
}
项目:DecompiledMinecraft    文件:TileEntitySign.java   
/**
 * 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()
{
    IChatComponent[] aichatcomponent = new IChatComponent[4];
    System.arraycopy(this.signText, 0, aichatcomponent, 0, 4);
    return new S33PacketUpdateSign(this.worldObj, this.pos, aichatcomponent);
}
项目:DecompiledMinecraft    文件:ServerScoreboard.java   
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;
}
项目:CustomWorldGen    文件:EntityTracker.java   
public void sendToTrackingAndSelf(Entity entityIn, Packet<?> packetIn)
{
    EntityTrackerEntry entitytrackerentry = (EntityTrackerEntry)this.trackedEntityHashTable.lookup(entityIn.getEntityId());

    if (entitytrackerentry != null)
    {
        entitytrackerentry.sendToTrackingAndSelf(packetIn);
    }
}
项目:BaseClient    文件:EntityTrackerEntry.java   
/**
 * Send the given packet to all players tracking this entity.
 */
public void sendPacketToTrackedPlayers(Packet packetIn)
{
    for (EntityPlayerMP entityplayermp : this.trackingPlayers)
    {
        entityplayermp.playerNetServerHandler.sendPacket(packetIn);
    }
}
项目:DecompiledMinecraft    文件:EntityPlayerMP.java   
private void sendTileEntityUpdate(TileEntity p_147097_1_)
{
    if (p_147097_1_ != null)
    {
        Packet packet = p_147097_1_.getDescriptionPacket();

        if (packet != null)
        {
            this.playerNetServerHandler.sendPacket(packet);
        }
    }
}