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; }
public override void HandleBlockDig(net.minecraft.src.Packet14BlockDig packet14blockdig) { if (playerEntity.isDead) { return; // CRAFTBUKKIT } net.minecraft.src.WorldServer worldserver = mcServer.GetWorldServer(playerEntity .dimension); if (packet14blockdig.status == 4) { playerEntity.DropCurrentItem(); return; } bool flag = worldserver.weirdIsOpCache = worldserver.worldProvider.worldType != 0 || mcServer.serverConfigurationManager.IsOp(playerEntity.username); bool flag1 = false; if (packet14blockdig.status == 0) { flag1 = true; } if (packet14blockdig.status == 2) { flag1 = true; } int i = packet14blockdig.xPosition; int j = packet14blockdig.yPosition; int k = packet14blockdig.zPosition; if (flag1) { double d = playerEntity.posX - ((double)i + 0.5D); double d1 = playerEntity.posY - ((double)j + 0.5D); double d3 = playerEntity.posZ - ((double)k + 0.5D); double d5 = d * d + d1 * d1 + d3 * d3; if (d5 > 36D) { return; } } net.minecraft.src.ChunkCoordinates chunkcoordinates = worldserver.GetSpawnPoint(); int l = (int)net.minecraft.src.MathHelper.Abs(i - chunkcoordinates.posX); int i1 = (int)net.minecraft.src.MathHelper.Abs(k - chunkcoordinates.posZ); if (l > i1) { i1 = l; } if (packet14blockdig.status == 0) { if (i1 > 16 || flag) { playerEntity.itemInWorldManager.Func_324_a(i, j, k, packet14blockdig.face); } else { playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange (i, j, k, worldserver)); } } else { if (packet14blockdig.status == 2) { playerEntity.itemInWorldManager.Func_22045_b(i, j, k); if (worldserver.GetBlockId(i, j, k) != 0) { playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange (i, j, k, worldserver)); } } else { if (packet14blockdig.status == 3) { double d2 = playerEntity.posX - ((double)i + 0.5D); double d4 = playerEntity.posY - ((double)j + 0.5D); double d6 = playerEntity.posZ - ((double)k + 0.5D); double d7 = d2 * d2 + d4 * d4 + d6 * d6; if (d7 < 256D) { playerEntity.netServerHandler.SendPacket(new net.minecraft.src.Packet53BlockChange (i, j, k, worldserver)); } } } } worldserver.weirdIsOpCache = false; }