Java 类net.minecraft.network.play.server.SPacketChunkData 实例源码

项目:CrystalMod    文件:ExplosionMaker.java   
public void finishChunks() {
    PlayerChunkMap playerChunkMap = serverWorld.getPlayerChunkMap();
    if (playerChunkMap == null) {
        return;
    }

    for (Chunk chunk : modifiedChunks) {
        chunk.setModified(true);
        chunk.generateSkylightMap(); //This is where this falls short. It can calculate basic sky lighting for blocks exposed to the sky but thats it.

        PlayerChunkMapEntry watcher = playerChunkMap.getEntry(chunk.xPosition, chunk.zPosition);
        if (watcher != null) {
            watcher.sendPacket(new SPacketChunkData(chunk, 65535));
        }
    }

    modifiedChunks.clear();
}
项目:HardVox    文件:OpSendChunks.java   
@Override
public int performOperation(Region region, PositionIterator chunk, World world, Chunk c, VectorMap<BlockData> blockMap,
        MutableVectorMap<IBlockState> hitStore) {
    // send the whole chunk again
    PlayerChunkMapEntry entry = ((WorldServer) world).getPlayerChunkMap().getEntry(c.x, c.z);
    if (entry != null) {
        entry.sendPacket(new SPacketChunkData(c, SPCD_SEND_ALL));
    }
    return 1;
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
/**
 * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
 */
public void handleChunkData(SPacketChunkData packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.doChunkLoad())
    {
        this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
    }

    this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);
    Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(packetIn.getChunkX(), packetIn.getChunkZ());
    chunk.fillChunk(packetIn.getReadBuffer(), packetIn.getExtractedSize(), packetIn.doChunkLoad());
    this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);

    if (!packetIn.doChunkLoad() || !(this.clientWorldController.provider instanceof WorldProviderSurface))
    {
        chunk.resetRelightChecks();
    }

    for (NBTTagCompound nbttagcompound : packetIn.getTileEntityTags())
    {
        BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
        TileEntity tileentity = this.clientWorldController.getTileEntity(blockpos);

        if (tileentity != null)
        {
            tileentity.readFromNBT(nbttagcompound);
        }
    }
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
/**
 * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
 */
public void handleChunkData(SPacketChunkData packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.doChunkLoad())
    {
        this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
    }

    this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);
    Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(packetIn.getChunkX(), packetIn.getChunkZ());
    chunk.fillChunk(packetIn.getReadBuffer(), packetIn.getExtractedSize(), packetIn.doChunkLoad());
    this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);

    if (!packetIn.doChunkLoad() || !(this.clientWorldController.provider instanceof WorldProviderSurface))
    {
        chunk.resetRelightChecks();
    }

    for (NBTTagCompound nbttagcompound : packetIn.getTileEntityTags())
    {
        BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
        TileEntity tileentity = this.clientWorldController.getTileEntity(blockpos);

        if (tileentity != null)
        {
            tileentity.readFromNBT(nbttagcompound);
        }
    }
}
项目: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;
    }
}
项目:Backmemed    文件:PlayerChunkMapEntry.java   
/**
 * Send packets to player for:
 *  - nearby tile entities
 *  - nearby entities that are leashed
 *  - nearby entities with
 */
public void sendNearbySpecialEntities(EntityPlayerMP player)
{
    if (this.sentToPlayers)
    {
        player.connection.sendPacket(new SPacketChunkData(this.chunk, 65535));
        this.playerChunkMap.getWorldServer().getEntityTracker().sendLeashedEntitiesInChunk(player, this.chunk);
    }
}
项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
/**
 * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
 */
public void handleChunkData(SPacketChunkData packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.doChunkLoad())
    {
        this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
    }

    this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);
    Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(packetIn.getChunkX(), packetIn.getChunkZ());
    chunk.fillChunk(packetIn.getReadBuffer(), packetIn.getExtractedSize(), packetIn.doChunkLoad());
    this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);

    if (!packetIn.doChunkLoad() || !(this.clientWorldController.provider instanceof WorldProviderSurface))
    {
        chunk.resetRelightChecks();
    }

    for (NBTTagCompound nbttagcompound : packetIn.getTileEntityTags())
    {
        BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
        TileEntity tileentity = this.clientWorldController.getTileEntity(blockpos);

        if (tileentity != null)
        {
            tileentity.handleUpdateTag(nbttagcompound);
        }
    }
}
项目:CustomWorldGen    文件:PlayerChunkMapEntry.java   
public boolean sentToPlayers()
{
    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);
            // chunk watch event - delayed to here as the chunk wasn't ready in addPlayer
            net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.world.ChunkWatchEvent.Watch(this.pos, entityplayermp));
        }

        return true;
    }
}
项目:CustomWorldGen    文件:PlayerChunkMapEntry.java   
/**
 * Send packets to player for:
 *  - nearby tile entities
 *  - nearby entities that are leashed
 *  - nearby entities with
 */
public void sendNearbySpecialEntities(EntityPlayerMP player)
{
    if (this.sentToPlayers)
    {
        player.connection.sendPacket(new SPacketChunkData(this.chunk, 65535));
        this.playerChunkMap.getWorldServer().getEntityTracker().sendLeashedEntitiesInChunk(player, this.chunk);
    }
}
项目:StructPro    文件:UWorld.java   
/**
 * Notify all nearby players about chunk changes
 * @param chunk Chunk to notify
 */
public void notifyChunk(Chunk chunk) {
    for (EntityPlayer player : world.playerEntities) {
        if (player instanceof EntityPlayerMP) {
            EntityPlayerMP playerMP = (EntityPlayerMP) player;
            if (    Math.abs(playerMP.chunkCoordX - chunk.xPosition) <= 32 &&
                    Math.abs(playerMP.chunkCoordZ - chunk.zPosition) <= 32) {
                playerMP.connection.sendPacket(new SPacketChunkData(chunk, 65535));
            }
        }
    }
}
项目:StructPro    文件:UWorld.java   
/**
 * Notify all nearby players about chunk changes
 * @param chunk Chunk to notify
 */
public void notifyChunk(Chunk chunk) {
    for (EntityPlayer player : world.playerEntities) {
        if (player instanceof EntityPlayerMP) {
            EntityPlayerMP playerMP = (EntityPlayerMP) player;
            if (    Math.abs(playerMP.chunkCoordX - chunk.xPosition) <= 32 &&
                    Math.abs(playerMP.chunkCoordZ - chunk.zPosition) <= 32) {
                playerMP.connection.sendPacket(new SPacketChunkData(chunk, 65535));
            }
        }
    }
}
项目:StructPro    文件:UWorld.java   
/**
 * Notify all nearby players about chunk changes
 * @param chunk Chunk to notify
 */
public void notifyChunk(Chunk chunk) {
    for (EntityPlayer player : world.playerEntities) {
        if (player instanceof EntityPlayerMP) {
            EntityPlayerMP playerMP = (EntityPlayerMP) player;
            if (    Math.abs(playerMP.chunkCoordX - chunk.x) <= 32 &&
                    Math.abs(playerMP.chunkCoordZ - chunk.z) <= 32) {
                playerMP.connection.sendPacket(new SPacketChunkData(chunk, 65535));
            }
        }
    }
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
/**
 * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
 */
public void handleChunkData(SPacketChunkData packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (packetIn.doChunkLoad())
    {
        this.clientWorldController.doPreChunk(packetIn.getChunkX(), packetIn.getChunkZ(), true);
    }

    this.clientWorldController.invalidateBlockReceiveRegion(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);
    Chunk chunk = this.clientWorldController.getChunkFromChunkCoords(packetIn.getChunkX(), packetIn.getChunkZ());
    chunk.fillChunk(packetIn.getReadBuffer(), packetIn.getExtractedSize(), packetIn.doChunkLoad());
    this.clientWorldController.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, 0, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, 256, (packetIn.getChunkZ() << 4) + 15);

    if (!packetIn.doChunkLoad() || !(this.clientWorldController.provider instanceof WorldProviderSurface))
    {
        chunk.resetRelightChecks();
    }

    for (NBTTagCompound nbttagcompound : packetIn.getTileEntityTags())
    {
        BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
        TileEntity tileentity = this.clientWorldController.getTileEntity(blockpos);

        if (tileentity != null)
        {
            tileentity.handleUpdateTag(nbttagcompound);
        }
    }
}
项目:Backmemed    文件:PlayerChunkMapEntry.java   
public void update()
{
    if (this.sentToPlayers && this.chunk != null)
    {
        if (this.changes != 0)
        {
            if (this.changes == 1)
            {
                int i = (this.changedBlocks[0] >> 12 & 15) + this.pos.chunkXPos * 16;
                int j = this.changedBlocks[0] & 255;
                int k = (this.changedBlocks[0] >> 8 & 15) + this.pos.chunkZPos * 16;
                BlockPos blockpos = new BlockPos(i, j, k);
                this.sendPacket(new SPacketBlockChange(this.playerChunkMap.getWorldServer(), blockpos));

                if (this.playerChunkMap.getWorldServer().getBlockState(blockpos).getBlock().hasTileEntity())
                {
                    this.sendBlockEntity(this.playerChunkMap.getWorldServer().getTileEntity(blockpos));
                }
            }
            else if (this.changes == 64)
            {
                this.sendPacket(new SPacketChunkData(this.chunk, this.changedSectionFilter));
            }
            else
            {
                this.sendPacket(new SPacketMultiBlockChange(this.changes, this.changedBlocks, this.chunk));

                for (int l = 0; l < this.changes; ++l)
                {
                    int i1 = (this.changedBlocks[l] >> 12 & 15) + this.pos.chunkXPos * 16;
                    int j1 = this.changedBlocks[l] & 255;
                    int k1 = (this.changedBlocks[l] >> 8 & 15) + this.pos.chunkZPos * 16;
                    BlockPos blockpos1 = new BlockPos(i1, j1, k1);

                    if (this.playerChunkMap.getWorldServer().getBlockState(blockpos1).getBlock().hasTileEntity())
                    {
                        this.sendBlockEntity(this.playerChunkMap.getWorldServer().getTileEntity(blockpos1));
                    }
                }
            }

            this.changes = 0;
            this.changedSectionFilter = 0;
        }
    }
}
项目:TFC2    文件:RegenChunkCommand.java   
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] params)
{
    EntityPlayerMP player;
    try {
        player = getCommandSenderAsPlayer(sender);
    } catch (PlayerNotFoundException e) {
        return;
    }

    if(!player.isCreative())
        return;

    WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension());

    if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 1)
    {
        int radius = Integer.parseInt(params[0]);

        for(int i = -radius; i <= radius; i++)
        {
            for(int k = -radius; k <= radius; k++)
            {
                int x = (((int)player.posX+i*16) >> 4);
                int z = (((int)player.posZ+k*16) >> 4);

                ChunkProviderServer cps = world.getChunkProvider();

                Chunk c = cps.chunkGenerator.provideChunk(x, z);
                Chunk old = world.getChunkProvider().provideChunk(x, z);
                old.setStorageArrays(c.getBlockStorageArray());
                c.setTerrainPopulated(false);
                c.onChunkLoad();
                c.setChunkModified();
                c.checkLight();
                cps.chunkGenerator.populate(c.xPosition, c.zPosition);
                net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
                c.setChunkModified();
                player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
            }
        }

        /*for(int i = -radius; i <= radius; i++)
        {
            for(int k = -radius; k <= radius; k++)
            {
                int x = (((int)player.posX+i*16) >> 4);
                int z = (((int)player.posZ+k*16) >> 4);

                ChunkProviderServer cps = world.getChunkProvider();

                Chunk c = cps.chunkGenerator.provideChunk(x, z);
                Chunk old = world.getChunkProvider().provideChunk(x, z);
                old.populateChunk(cps, cps.chunkGenerator);

                if (c.isTerrainPopulated())
                {
                    if (cps.chunkGenerator.generateStructures(c, c.xPosition, c.zPosition))
                    {
                        c.setChunkModified();
                    }
                }
                else
                {
                    c.checkLight();
                    cps.chunkGenerator.populate(c.xPosition, c.zPosition);
                    net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
                    c.setChunkModified();
                }

                player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
            }
        }*/
    }
    else if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 2 && params[1].equalsIgnoreCase("hex"))
    {
        execute(server, sender, new String[] {params[0]});
        IslandMap map = Core.getMapForWorld(world, player.getPosition());
        HexGenRegistry.generate(Core.getMapForWorld(world, player.getPosition()), map.getClosestCenter(player.getPosition()), world);
    }
}
项目:TFC2    文件:RegenChunkCommand.java   
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] params)
{
    EntityPlayerMP player;
    try {
        player = getCommandSenderAsPlayer(sender);
    } catch (PlayerNotFoundException e) {
        return;
    }

    if(!player.isCreative())
        return;

    WorldServer world = server.worldServerForDimension(player.getEntityWorld().provider.getDimension());

    if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 1)
    {
        int radius = Integer.parseInt(params[0]);

        for(int i = -radius; i <= radius; i++)
        {
            for(int k = -radius; k <= radius; k++)
            {
                int x = (((int)player.posX+i*16) >> 4);
                int z = (((int)player.posZ+k*16) >> 4);

                ChunkProviderServer cps = world.getChunkProvider();

                Chunk c = cps.chunkGenerator.provideChunk(x, z);
                Chunk old = world.getChunkProvider().provideChunk(x, z);
                old.setStorageArrays(c.getBlockStorageArray());
                c.setTerrainPopulated(false);
                c.onChunkLoad();
                c.setChunkModified();
                c.checkLight();
                cps.chunkGenerator.populate(c.xPosition, c.zPosition);
                net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
                c.setChunkModified();
                player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
            }
        }

        /*for(int i = -radius; i <= radius; i++)
        {
            for(int k = -radius; k <= radius; k++)
            {
                int x = (((int)player.posX+i*16) >> 4);
                int z = (((int)player.posZ+k*16) >> 4);

                ChunkProviderServer cps = world.getChunkProvider();

                Chunk c = cps.chunkGenerator.provideChunk(x, z);
                Chunk old = world.getChunkProvider().provideChunk(x, z);
                old.populateChunk(cps, cps.chunkGenerator);

                if (c.isTerrainPopulated())
                {
                    if (cps.chunkGenerator.generateStructures(c, c.xPosition, c.zPosition))
                    {
                        c.setChunkModified();
                    }
                }
                else
                {
                    c.checkLight();
                    cps.chunkGenerator.populate(c.xPosition, c.zPosition);
                    net.minecraftforge.fml.common.registry.GameRegistry.generateWorld(c.xPosition, c.zPosition, world, cps.chunkGenerator, world.getChunkProvider());
                    c.setChunkModified();
                }

                player.connection.sendPacket(new SPacketChunkData(cps.provideChunk(x, z), 0xffffffff));
            }
        }*/
    }
    else if(player.getEntityWorld().provider.getDimension() == 0 && params.length == 2 && params[1].equalsIgnoreCase("hex"))
    {
        execute(server, sender, new String[] {params[0]});
        IslandMap map = Core.getMapForWorld(world, player.getPosition());
        HexGenRegistry.generate(Core.getMapForWorld(world, player.getPosition()), map.getClosestCenter(player.getPosition()), world);
    }
}
项目:Backmemed    文件:INetHandlerPlayClient.java   
/**
 * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
 */
void handleChunkData(SPacketChunkData packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
/**
 * Updates the specified chunk with the supplied data, marks it for re-rendering and lighting recalculation
 */
void handleChunkData(SPacketChunkData packetIn);