示例#1
0
        public virtual void OnUpdate()
        {
            net.minecraft.src.WorldServer worldserver = playerManager.GetMinecraftServer();
            if (dirtyCount == 0)
            {
                return;
            }
            if (dirtyCount == 1)
            {
                int i  = chunkX * 16 + minX;
                int l  = minY;
                int k1 = chunkZ * 16 + minZ;
                SendPacketToPlayersInInstance(new net.minecraft.src.Packet53BlockChange(i, l, k1,
                                                                                        worldserver));
                if (net.minecraft.src.Block.isBlockContainer[worldserver.GetBlockId(i, l, k1)])
                {
                    UpdateTileEntity(worldserver.GetBlockTileEntity(i, l, k1));
                }
            }
            else
            {
                if (dirtyCount == 10)
                {
                    minY = (minY / 2) * 2;
                    maxY = (maxY / 2 + 1) * 2;
                    int j  = minX + chunkX * 16;
                    int i1 = minY;
                    int l1 = minZ + chunkZ * 16;
                    int j2 = (maxX - minX) + 1;
                    int l2 = (maxY - minY) + 2;
                    int i3 = (maxZ - minZ) + 1;
                    SendPacketToPlayersInInstance(new net.minecraft.src.Packet51MapChunk(j, i1, l1, j2, l2, i3, worldserver));
                    List <TileEntity> list = worldserver.GetTileEntityList(j, i1, l1, j + j2,
                                                                           i1 + l2, l1 + i3);
                    for (int j3 = 0; j3 < list.Count; j3++)
                    {
                        UpdateTileEntity((net.minecraft.src.TileEntity)list[j3]);
                    }
                }
                else
                {
                    SendPacketToPlayersInInstance(new net.minecraft.src.Packet52MultiBlockChange(chunkX, chunkZ, dirtyBlocks, dirtyCount, worldserver));
                    for (int k = 0; k < dirtyCount; k++)
                    {
                        // CRAFTBUKKIT start -- Fixes TileEntity updates occurring upon a multi-block change; dirtyCount -> dirtyBlocks[i]
                        int j1 = chunkX * 16 + (dirtyBlocks[k] >> 12 & 0xf);
                        int i2 = dirtyBlocks[k] & 0xff;
                        int k2 = chunkZ * 16 + (dirtyBlocks[k] >> 8 & 0xf);
                        // CRAFTBUKKIT end

                        if (net.minecraft.src.Block.isBlockContainer[worldserver.GetBlockId(j1, i2, k2)])
                        {
                            //System.Console.Out.WriteLine("Sending!");
                            UpdateTileEntity(worldserver.GetBlockTileEntity(j1, i2, k2));
                        }
                    }
                }
            }
            dirtyCount = 0;
        }
示例#2
0
 public override void HandleUpdateSign(net.minecraft.src.Packet130UpdateSign packet130updatesign)
 {
     if (this.playerEntity.isDead)
     {
         return;                           // CRAFTBUKKIT
     }
     net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity.dimension);
     if (worldserver.BlockExists(packet130updatesign.xPosition, packet130updatesign.yPosition, packet130updatesign.zPosition))
     {
         net.minecraft.src.TileEntity tileentity = worldserver.GetBlockTileEntity(packet130updatesign.xPosition, packet130updatesign.yPosition, packet130updatesign.zPosition);
         if (tileentity is net.minecraft.src.TileEntitySign)
         {
             net.minecraft.src.TileEntitySign tileentitysign = (net.minecraft.src.TileEntitySign)tileentity;
             if (!tileentitysign.GetEditable())
             {
                 mcServer.LogWarning((new java.lang.StringBuilder()).Append("Player ").Append(playerEntity.username).Append(" just tried to change non-editable sign").ToString());
                 this.SendPacket(new Packet130UpdateSign(packet130updatesign.xPosition, packet130updatesign.yPosition, packet130updatesign.zPosition, tileentitysign.Lines)); // CRAFTBUKKIT
                 return;
             }
         }
         for (int i = 0; i < 4; i++)
         {
             bool lineValid = true;
             if (packet130updatesign.signLines[i].Length > 15)
             {
                 lineValid = false;
             }
             else
             {
                 for (int l = 0; l < packet130updatesign.signLines[i].Length; l++)
                 {
                     if (net.minecraft.src.ChatAllowedCharacters.allowedCharacters.IndexOf(packet130updatesign.signLines[i][l]) < 0)
                     {
                         lineValid = false;
                     }
                 }
             }
             if (!lineValid)
             {
                 packet130updatesign.signLines[i] = "!?";
             }
         }
         if (tileentity is net.minecraft.src.TileEntitySign)
         {
             int x = packet130updatesign.xPosition;
             int y = packet130updatesign.yPosition;
             int z = packet130updatesign.zPosition;
             net.minecraft.src.TileEntitySign tileentitysign1 = (net.minecraft.src.TileEntitySign)tileentity;
             for (int j1 = 0; j1 < 4; j1++)
             {
                 tileentitysign1.Lines[j1] = packet130updatesign.signLines[j1];
             }
             tileentitysign1.SetEditable(false);
             tileentitysign1.OnInventoryChanged();
             worldserver.MarkBlockNeedsUpdate(x, y, z);
         }
     }
 }