protected void setBlock(Position p, Block b, bool recalculateConnections) { Debug.Log("set " + p + " to " + b + " from " + p.getBlock() + " in " + this); if (!loaded) { setBlockQueue.Enqueue(new KeyValuePair <Position, Block>(p, b)); return; } lock (blocks) { if (b.getMeshID() >= 0 && b.isTransparent()) { liquid = b as Liquid; if (liquid != null && !fluids.ContainsKey(liquid.getPrefab())) { fluids.Add(liquid.getPrefab(), null); MainThread.runAction(() => fluids[liquid.getPrefab()] = GameObject.Instantiate(liquid.getPrefab(), empty.transform).gameObject); } } //Debug.Log("Updating block at " + p.getRelativeCoords() + " (" + p + ")"); ServerNetworkManager.updateBlock(p, b); if (blocksModified == null) { blocksModified = new BitArray[size, size]; } if (blocksModified[p.getRelativeX(), p.getRelativeY()] == null) { blocksModified[p.getRelativeX(), p.getRelativeY()] = new BitArray(size); } blocksModified[p.getRelativeX(), p.getRelativeY()][p.getRelativeZ()] = true; untouchedChunk = false; modifiedSinceSave = true; fluidMeshRebuildingNeeded = fluidMeshRebuildingNeeded || blocks[p.getRelativeX(), p.getRelativeY(), p.getRelativeZ()] is Liquid; terrainMeshRebuildingNeeded = terrainMeshRebuildingNeeded || blocks[p.getRelativeX(), p.getRelativeY(), p.getRelativeZ()] is Solid; lock (blockChangeListeners) { blockChangeListeners.Remove(blocks[p.getRelativeX(), p.getRelativeY(), p.getRelativeZ()]); } blocks[p.getRelativeX(), p.getRelativeY(), p.getRelativeZ()] = b; blockUpdated(b, true); faceRecalculationNeeded = true; if (recalculateConnections) { BackgroundThread.runAction(() => recalculateFaceConnections()); } Debug.Log("now " + p.getBlock() + " | " + b); } }