本文整理汇总了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);
}
}
}
示例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_);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
示例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_);
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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()));
}
}
}
示例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);
}
}
示例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;
}
}